Windows Service with a Startup Winform


I'm looking for a sample of creating a windows service, that has a WinForm.
The form allows the user to configur parameters for the Service.
For example - SQL Server connection parameters, and output directory.

The form should load when the service starts, and wait for the user input.
After the user has configured the parameters, and selects "Connect",
the form will save the configuration, then it will be unloaded
and the service continues running.

When the service is detecting a previous configuration,
it will wait for 30 seconds before using the previous configuration.

I know it's possible to use input arguments, but we prefer a GUI.

any help will be appreciated,
Thank you.
Who is Participating?
Typically this is achieved by creating a separate EXE, In fact, this is exactly how SQL Server does it too.  If you look in your startup folder, you will notice there is a program call the "Service Manager".  This is the exe that you see running in your system tray to control SQL Server.  Because it is a separate exe, it has the added ability to connect to the SQL Server Service running on other computers as well.  

Services should never have a UI becuase they are meant to be run by the system.  A UI requires a person to be logged in interactively.  

C# provides a really easy to use "Service Controller" control in the toolbox that you just drop on your form that will provide start, stop and pause functionality out of the box.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.