Wednesday, August 20, 2014

Installing a Windows Service More Than Once On the Same Machine

If you need to install a windows service more than once on the same machine (maybe to create two separate environments), the service has to be created with a different name. The tool to do this is sc.exe which is an exe that is provided in the standard Windows install.

The command is
sc create [Service Name] binPath= [Service Path] DisplayName= [Display Name]

where
Service Name: The unique name you want to give to the instance of the service.
Service Path: The complete path to the service exe file, including the exe file
Display Name: Name you want to display in the Windows Services app.

NOTE THAT THERE MUST BE A SPACE AFTER EACH EQUALS SIGN.

For example
sc create MyServiceName binPath= "C:\My Location\MyService.exe" DisplayName= "My Service 02"

To delete a registered instance of a service use 
sc delete [Service Name]

To alter the description for the service use
sc description [Service Name] "Your new Description"