I am trying to spawn a process that will survive a windows log off. I have had mixed success and so it's time to ask questions. At this stage, I am primarily interested in spawning a process (lets call it ProcessX) that requires no desktop interaction, it just needs to be able to talk over TCP connections or Serial RS232 connections.
Scenario 1: If I create a service and call the CreateProcess from the service, the spawned process survives a Windows log off. ie. after I log off and then log back on, the process is still functioning. While the system is logged off, the process is still functioning. So... no problem here. I assume it's running in some type of system process space and is sheltered from such log off requirements.
Scenario 2: If I am logged in and I manually stop and restart the process and then log off, then the process dies. I tried capturing and ignoring the log off request, but it just cases the Windows shutdown to freeze and XP asks me to manually terminate the process.
Scenario 3: If I used the SysInternal's tool psexec to spawn the process (instead of using CreateProcess programatically, then it manages to survive a log off. eg. psexec -i -s -d "C:/ProcessX.exe"
Question: Does anyone know how to use CreateProcess to spawn a process that can survive a log off (like psexec somehow manages to do)?
Thanks in advance,