KTS_HOWTO: start an application that continues to run after logout

By design when you logout KTS session, or the session is closed due to network problem all applications started from inside the session are terminated. This seems reasonable to me, because I don't want unusable "zombie" processes to choke down my box in case of session disconnection.

Here is what happens in the background: when KTS detects either network failure or that %COMSPEC%(command prompt) process has terminated, KTS closes its internal session job object(CreateJobObject; CloseHandle) thus forcing the OS to terminate all the processes that where created from %COMSPEC%.

Still it is possible to create process that will continue to run after logout/disconnection. The trick is to start it in a way that it doesn't get assigned to the session job object. We could do that by asking a process running outside KTS to start the application. Luckily windows provides the RunAs service which does exactly what we want.

For example to start notepad using RunAs type the following:
C:\Documents and Settings\kpym>runas /user:kpym notepad.exe
Enter password for kpym:
Attempting to start "notepad.exe" as user "kpym"...

C:\Documents and Settings\kpym>

Saturday, October 22, 2005

© 2002 - 2008 Kroum Grigorov
This page is powered by Blogger. Isn't yours?