Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Using CreateProcess to spawn a process that survives log off

Hi all,

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,
Justin

Comments

  • Avinash.VAvinash.V Member Posts: 11
    : Hi all,
    :
    : 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,
    : Justin


    if u wish your process not to die, there is a method
    as u mentioned the process will die if u end it manually,because it's security attributes were normal. infact default.
    u can change it by adding multiple threads of the process with security attributes high(but always less than 8).ie, u can make the process system process.it will run whenever explorer.exe runs and stops whenever explorer.exe stops.u cannot manually stop it
    so i think u understand.
Sign In or Register to comment.