Luis Custodio bio photo

Luis Custodio

A automation oriented developer, travelling the world

Email Twitter Github Stackoverflow

GOAL Create an windows service based on a Console Application. My end solution is aggregation of the results with some clean up.

Mainly the method OnStart and OnStop need to be implemented, they are part of ServiceBase class. With Visual Studio, go to new project and pick Windows Service (C# in my case).

Override the OnStart and OnStop method. Basic tutorial that helps to create the basic steps. (it’s ugly but quite helpful)

Install the service

How to install windows services with PowerShell:

My goal is manage everything with the build server, so I just rely on bash.


    New-Service -name cimpltestservice -displayName "Cimpl Test" -binaryPathName "C:\Temp\Service\Release\Etelesolv.EmailService.exe"
    New-Service -name cimplservice-cipweb -displayName "Cimpl Service - Cip Web" -binaryPathName "C:\cimplservices\cip\web\Etelesolv.EmailService.exe"


    Get-WmiObject win32_service -filter "name='cimpltestservice'"


In theory this should work, but in my case it just flaged the service to be removed and I had to restart windows:

    (Get-WmiObject Win32_Service -filter "name='cimplservice-webcip'").Delete()

In other hand this works like a charm:

.\sc.exe delete cimplservice-webstage

How to install windows services with cmd (boring):

sc create cimplservice-webstage binPath="C:\cimplservices\cip\web\Etelesolv.TM.SendingInvoices.Console.exe" DisplayName="Cimpl Service - Web Stage" start=demand


Send me email if any question…