Install a Windows service with a custom name

I have an exe file with windows service. To install it, I use the command:

installutil myService.exe / ShowCallStack

Then I can see "service1" specified in the "Services" window.

My question is whether it is possible to install 2 instances of the same service (using the same exe), but with different names. I want to do this without changing the source code.

thanks

+6
windows windows-services
source share
3 answers

In the past, I used something like a script. Edit the service names, save them as VBS and run.

Const ExistingServiceName = "Service1" strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") set objExistingService = objWMIService.Get("Win32_Service.Name='" & ExistingServiceName & "'") Set objService = objWMIService.Get("Win32_BaseService") Const NewServiceName = "Service2" errReturn = objService.Create (NewServiceName, NewServiceName, objExistingService.PathName, OWN_PROCESS ,NOTIFY_USER ,"Manual" , NOT_INTERACTIVE ,".\LocalSystem" ,"") 
0
source share

ProjectInstaller your service have a ProjectInstaller class? If you add ProjectInstaller to your service, you can edit the DisplayName property of the ProjectInstaller ServiceInstaller object . This will change the name from "Service1" to whatever you want. ProjectInstallers walkthrough can be found on MSDN here .

+2
source share

during installation installation, you can use InstallUtil.exe.config, so my dirty hack looked like this:

In ProjectInstaller.designer.cs

  this.Service1.Description = ConfigurationManager.AppSettings["ServiceDescription"] != null ? ConfigurationManager.AppSettings["ServiceDescription"] : "bla, bla, bla"; this.Service1.DisplayName = ConfigurationManager.AppSettings["DisplayName"] != null ? ConfigurationManager.AppSettings["DisplayName"] : "Service One"; this.Service1.ServiceName = ConfigurationManager.AppSettings["ServiceName"] != null ? ConfigurationManager.AppSettings["ServiceName"] : "Service1"; 

in InstallUtil.exe.config:

 <configuration><appSettings><add key="ServiceName" value="Service1" /><add key="DisplayName" value="Service One" /><add key="ServiceDescription" value="bla, bla, bla" /></appSettings></configuration> 

can't get how to send xml here

amuses

0
source share

All Articles