Walkthrough: Creating a Windows Service Application in the Component Designer


BUG: “The specified service has been marked for deletion” error message when you reinstall a service in Visual Studio .NET

solutions: a) restart the machine b) stop the service, close the service console, THEN uninstall the service (NOTE: I have not tested b))
method b) is backed-up by Lukas Beeler’s experience: Always close services.msc when installing or upgrading programs!



Manually creating a service

How to manually install a service in Windows


NOTE: uses the command-line tool sc


  1. Uninstall the old service (if exists)
    • sc delete "<service name>"
  2. Install the new service
    • sc create "<service name>" binPath= "\\path\to\service.exe"
    • note the upper-case P and the space after the equals
  3. Configure user credentials
    • this will be with services.msc as per usual
  4. Configure auto-start and restart



Use the Windows Task Scheduler !?



Think about using the Windows Task Scheduler instead

A Windows Service is the wrong solution to scheduling one-off custom processes. The right solution for scheduling simple processes is the Windows Task Scheduler.


tutorial on use


launch from Start > run (or command-line):

taskschd.msc /s




Unit-test a core-dll, not the service. The service only exposes Start and Stop methods -- testing that is an integration test. Build your unit-tests on the core-dll methods.


See Also

notes on debugging a windows service included