Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the name of a windows service?

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

like image 905
Prady Avatar asked Oct 08 '10 03:10

Prady


People also ask

Can I rename a Windows service?

Open regedit.exe (Registry Editor). Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and find the subkey with your service's name. Right-click the key you found in step #3, and select Rename. Enter the new name for the service.

How do I install a Windows service with a different name?

You need to copy your service executable to a separate directory and use InstallUtil.exe to give it a different service name. From a command prompt, you'll need to use InstallUtil to install both instances of your service. For instructions on how to use InstallUtil, see Installer Tool (InstallUtil.exe).

How do I change the service name in Windows Visual Studio?

In Visual Studio 2010, you could double click the entry for the service file in the Solution Explorer (named "AService" in your case). In the properties window, just change the entry under "ServiceName".

How do I change the description of a Windows service?

Service descriptions are kept in the registry under LocalMachine\System\CurrentControlSet\services and then open the key for your service name, one of the keys is Description which holds the description text. Change that and restart the computer.


2 Answers

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!).

like image 84
ewall Avatar answered Oct 14 '22 09:10

ewall


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.

like image 23
Jeff LaFay Avatar answered Oct 14 '22 09:10

Jeff LaFay