tags:

views:

263

answers:

6

I have a c# application which is launched under the System account on a machine and presents some dialogs to a user. When a regular user logs off the application is terminated as well. I would have thought that since its running under the system account it would continue to run despite the user not being logged in.

Any info on why this happens would be appreciated.

+5  A: 

Is your application a service? It sounds like what you want is a service. Note that you can run any process as any user, but that doesn't make it a service. If your process is implemented as a service, then it will continue running even with no users logged in.

William Leara
...and then, since services are strongly discouraged from having UI, use a separate process over some remoting interface to communicate with the user.
Michael Petrotta
+1  A: 

You need to run your application as a Windows Service.

Jonas Elfström
A: 

Because the process was started by explorer.exe, it will be terminated when the user logs off regardless of what account it's running under. That's simply the way windows works. To allow the process to continue running it needs to be a service or possibly started by the task scheduler.

jmatthias
+2  A: 

This is a security feature when a users session ends applications they invoked are terminated. If you need an application to run outside of a users session you need a service however since its in its own session services cant "reach into" the users session with messages and such.

Copas
+4  A: 

If you want your app to keep running after the user has logged off (e.g. to maintain state for as long as the computer is running), you need a service. However, services are strongly discouraged from displaying UI. If you need both long-running and UI, consider writing a service to store your data, and an application that runs each time a user logs in that shows UI and interacts with the service.

Joe White
+1  A: 

You will need to create your application as a windows service. If your application displays dialogs then you would need to check the 'Allow service to interact with desktop' and run it under local system account.

However, a better approach would be to expose a queryable interface from your application using WCF or Remoting that you can display to users using a separate application. If you want notifications from your app when no one is logged on then you might want to consider sending emails or posting events to a separate WCF/ Web Services/ Remoting endpoint.

ilias