How do I change the name of my Windows service?

删除回忆录丶 提交于 2019-12-03 09:22:54

You have to add an installer class to your Windows service project. Then in its designer you add ServiceInstaller and ServiceProcessInstaller, in objects of these two classes you can specify Service name, display name for service, user etc.

You can see detailed explanation here:
http://utkarshpuranik.wordpress.com/2010/06/07/creating-installing-debugging-windows-services/

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

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".

in VS2012 and 2015, if you want to change it in VS designer, double click on your service class file e.g. MyCustomService.cs and then in design view right click and choose Properties.

that gives you the option to visually change the service name.

It depends on the way you install it

  • If you use SC.EXE then just change the display name parameter
  • If you use ServiceInstaller Class then change its DisplayName

None of the above work for me, so sharing what works actually Go to your file "ProjectInstaller.Designer.cs" and upadate the line:

this.serviceInstaller1.ServiceName = "Updated Name";

It should be under method: InitializeComponent()

Hope it helps someone!!!

A picture sometime worth thousand words so i thought i gave you this image with annotation:

It should be simple.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!