Any way to redefine a Windows.NET service name without recompiling?

I have a Windows service executable, which I know is written in .NET, which I need to install under a different service name in order to avoid conflict. In any case, the installation will not indicate the name of the service. If I only have access to the binary, is there a way to override the service name when I install it using installutil?

+50
windows-services
Nov 09 '09 at 23:03
source share
5 answers

Do you need to use InstallUtil? Here are the commands you need to do with sc:

sc create MyService binPath= "MyService.exe" DisplayName= "MyService" sc description MyService "My description" 

Link: http://support.microsoft.com/kb/251192

+82
Nov 09 '09 at 23:47
source share

It is not true that InstallUtil does not allow you to configure the service name. I do it all the time like this

 InstallUtil.exe /servicename="<service name>" "<path to service exe>" 
+21
Feb 06 '13 at
source share
  • Add installer to your service
  • Add a method to get the name CustomService

     private void RetrieveServiceName() { var serviceName = Context.Parameters["servicename"]; if (!string.IsNullOrEmpty(serviceName)) { this.SomeService.ServiceName = serviceName; this.SomeService.DisplayName = serviceName; } } 
  • cause install and uninstall

     public override void Install(System.Collections.IDictionary stateSaver) { RetrieveServiceName(); base.Install(stateSaver); } public override void Uninstall(System.Collections.IDictionary savedState) { RetrieveServiceName(); base.Uninstall(savedState); } 
  • installutil /servicename="My Service [SysTest]" d:\pathToMyService\Service.exe

Source

+20
Aug 12 '14 at 8:38
source share

enter image description here

It worked for me!

I hope someone can use this.

+3
Jun 14 '13 at 19:06 on
source share

Try installing the service using sc.exe. A quick search will give a lot of documentation. Using this tool, you can easily modify existing services and / or add new ones, including names.

Edit: I install my .NET services with this tool.

+1
Nov 09 '09 at 23:46
source share



All Articles