How can I change the name of a windows service?

46,830

Solution 1

In your win service class that derives from ServiceBase, there is a property that is inherited that you can set called ServiceName. You could make an app.config, add a setting for the service name and have your win service class assign that property accordingly. That way each service name will be unique as long as you change the setting in the app.config.

Solution 2

Service name can also be edited via ProjectInstaller design mode. There is a property called ServiceName in the ServiceInstaller.

Solution 3

The configuration for Windows services are stored in the Registy, under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services... You will probably want to change both the name of the key (the "folder", and the real name of the service here) and the value "Display Name".

It might be better to use a tool like SC.EXE to configure services, to avoid causing problems with bad Registry edits. Although SC can't rename a service in place, it does allow you to delete and create services (just be sure to get all the settings right!).

Share:
46,830

Related videos on Youtube

Prady
Author by

Prady

Salesforce's Force.com platform consultant having worked with enterprise clients like New York times, Cisco and company85 to name a few. Over the last 12 years, I have developed a wide range of websites using HMTL, DHTML,wordpress, .net, SQL server and applications using the force.com platform including sites for startup companies , small businesses and Enterprise clients. Currently working with Cm-Focus LLC - Salesforce developers and Consultants 1: http://www.cm-focus.com@pradykr also representing cloudtrainer.org

Updated on August 19, 2020

Comments

  • Prady
    Prady over 3 years

    I have a windows service application developed in C#. The same service needs to be run with different config files. To run on these on the same machine I would need to change the name of the service. I can create multiple copies of the solution, but not sure how to change the names of the services.

    Thanks

  • Prady
    Prady over 13 years
    Sorry if my question was bit confusing... I wanted to change the name of the service in the solution itself. How can it be done?
  • Joel Mitchell
    Joel Mitchell about 11 years
    This example goes through it in a bit more detail should anyone need it: codeproject.com/Articles/21320/…
  • Lukas S.
    Lukas S. over 9 years
    For Joel's link, the specifics of how to obtain the ServiceName from app.config from within the installer didn't work for me (probably out of date since it was written for .NET 2.0), but this solution worked fine: stackoverflow.com/questions/8516701/…
  • Kai Hartmann
    Kai Hartmann about 6 years
    Additionally, the name coming up in the EventLog is set in the Service design mode itself, through property ServiceName.