what platform are you developing this program for? windows? linux? the way to do it is very different for each. either way, a daemon (linux/unix) running as root or a service (windows) running as the local system account would be where I'd start. have the daemon/service communicate with the port and write another program that uses IPC (interprocess communications) to run at the user level and control the service/daemon.