Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find "Display name" of a service in .net?

I have a service which is running in a system in several instances. I need to find DISPLAY_NAME of the service from the service. I've tried ServiceBase.ServiceName but it returns (probably) the name of service from the project installer, which is at least in this case useless.

The service is installed by installutil with a parameter /name=.

Edit

I have a workaround based on Imran Balouch answer. I read the name in the installer Me.Context.Parameters("name") and write it to ImagePath registry subkey and read it with Environment.GetCommandLineArgs in a service.

like image 838
IvanH Avatar asked Jun 12 '12 11:06

IvanH


1 Answers

Have you added ProjectInstaller in your windows service project? If yes than in ProjectInstaller you add ServiceInstaller for your service, and in that ServiceInstaller you can specify the display name of the service. Select that serviceinstaller and in properties set its Display Name or in InitializeComponent of ProjectInstaller.Designer.cs or ProjectInstaller.Designer.vb you can specify the display name as:

this.yourServiceInstaller.DisplayName = "Service Display Name";
like image 176
Imran Balouch Avatar answered Oct 29 '22 08:10

Imran Balouch