Search code examples
c#windowslogoff

Why does an application running as the system account on windows when logging off


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.


Solution

  • 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.