views:

263

answers:

4

I have a windows service executable that I know is written in .NET which I need to install under a different service name to avoid a conflict. The install doesn't provide anyway to specify a service name. If I only have access to the binary, is there anyway to override the service name when I install it with installutil?

A: 

I don't think there is a way.

I have done this before with a service I have written, but I had had to handle it myself in the code of the service installer. I passed in a /name parameter to InstallUtil, and then used it in the installer (by getting it from the Context.Parameters) to alias the service.

Unless the service you are using has this kind of functionality, it is not possible (certainly not using any documented feature of InstallUtil).

adrianbanks
A: 

Try installing your service with sc.exe. A quick search will yield lots documentation. With that tool it's easy to modify existing services and/or add new ones -- including names.

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

jsw
+4  A: 

Do you have to use InstallUtil? Here are the commands to do what you want using sc:

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

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

Josh Yeager
This looks like exactly what I want -- however I can't get it to work. I just keep getting a "usage" message.
Nathan
My problem was that there apparently *must* be a space between the equal sign and the binPath value, e.g. sc create ahSchedulerService binPath= "MyService.exe", not sc create ahSchedulerService binPath="MyService.exe".
Nathan
Ah, I forgot about that. Sorry for giving you a bad example.
Josh Yeager
A: 

Hi! I am a developer for an open source windows service hosting framework called Daemoniq. I understand how making a reusable windows service can be a bit of a pain using System.Service process. This is the reason why setting common service properties like serviceName, displayName, description and serviceStartMode is one of its features. You can download it from http://daemoniq.org

Current features include:

  • container agnostic service location via the CommonServiceLocator
  • set common service properties like serviceName, displayName, description and serviceStartMode via app.config
  • run multiple windows services on the same process
  • set recovery options via app.config
  • set services depended on via app.config
  • set service process credentials via command-line
  • install, uninstall, debug services via command-line

Thanks!

jake.stateresa