Windows Service with a Startup Winform

Posted on 2009-04-23
Last Modified: 2012-05-06

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.
Question by:avitalk
    1 Comment
    LVL 9

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now