Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the name of my Windows service?

I have a Windows Service and want to change the name of it (as it appears in the Services application). But I'm unsure of the correct way to do so. It appears to be the ServiceName property and searching through my solution I found this:

namespace SI.AService.AService {     partial class AService     {         /// <summary>          /// Required designer variable.         /// </summary>         private System.ComponentModel.IContainer components = null;          /// <summary>         /// Clean up any resources being used.         /// </summary>         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>         protected override void Dispose(bool disposing)         {             if (disposing && (components != null))             {                 components.Dispose();             }             base.Dispose(disposing);         }          #region Component Designer generated code          /// <summary>          /// Required method for Designer support - do not modify          /// the contents of this method with the code editor.         /// </summary>         private void InitializeComponent()         {             //              // AService             //              this.ServiceName = "Company.AService.AService";          }          #endregion     } } 

So this seems to be autogenerated code. What's the proper way of changing it? It says "do not modify the contents of this method with the code editor." So where do I modify it then?

Update: I was updating my Windows Service through the build process in Visual Studio, which apparently has no effect on name changes set up in the service installer. I think it runs an uninstall and install command with the InstallUtil. Instead I had to go to the output directory of the build process where 2 files are located. An msi-file and a setup.exe file. The msi installs the service, BUT there is no name changes. However if I run the setup.exe, it does the same but name changes to the service are included. So I guess the projectinstaller/serviceinstaller are included in the setup.exe and not the other.

Lastly, thank you all for your help.

like image 414
Kasper Hansen Avatar asked Mar 04 '11 08:03

Kasper Hansen


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 Windows service description?

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.


1 Answers

You might have added an installer by right clicking the design view of your Windows service class. If you have done this then you will find a ProjectInstaller class within your WindowsService project.

By selecting this ProjectInstaller class you will find two installers on its design view -> 1.ServiceInstaller1 2.ServiceProcessInstaller1

Right click the ServiceInstaller1 and select properties. In the properties window change the ServiceName to the name you want to give to your service.

Hope this works...

like image 64
Harun Avatar answered Oct 21 '22 05:10

Harun