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.
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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With