Search code examples
c#windows-servicesstartup

How to start my Application on Server startup


I have a Windows Forms Application which runs on a server. I need this Application to always start automatically. Even if the Server just gets restartet and nobody logs into it the Application should run. So the solutions with Registry don´t work here. I than read into Windows Services but it seems like I can´t start a WinForm Application with it.

Does anyone have an idea how I can achieve this automatic Start on Server startup?


Solution

  • The way we do things like that is that we create a Windows Service which runs without the need to have anyone logged in, and then if there is a need we have a separate GUI application (WinForms in your case) which interacts with the service, when needed.

    The communication between the GUI application and the Windows Service is usually done by means of named pipes, but if you can get away with something simpler, like the GUI application saving a configuration file for the service to pick up, you might make it easier for you.