Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the Description of my Windows Service

According to this answer it seems that there is no official way to set a version for a Windows Service. However this can be done by inserting it into its Description or DisplayName.

I would like to be able to change that version number without needing to delete and reinstall the service. But I couldn't find a way to set the Description except for in the installation itself.

So, is there a way, and what is it, to change a Service's Description without reinstalling it?

Preferably using .Net. The Service itself is also .Net if that matters.

like image 717
ispiro Avatar asked May 10 '18 20:05

ispiro


2 Answers

This can be accomplished using the SC.exe utility with the command:

sc description <ServiceName> "Any Description you like."

This command could be called from a command window opened as administrator or from a .Net application provided that the service has already been created.

like image 156
Maineac Avatar answered Oct 20 '22 13:10

Maineac


Though this is not a pure .NET solution, it can be implemented in .NET, and it is one of the only MS-supported methods of reconfiguring a service. Plus, it doesn't require direct registry manipulation (best avoided if possible).

You can change the description of a Windows service by using the Windows command-line service controller utility, SC.exe.

You can exec the command you need to execute from your .NET code, or call it from a shell or script, such as CMD.exe or PowerShell.

sc.exe config YourServiceName displayName= "Your service description..."

Note:

  • Detailed information on the SC config command can be found here: MS Docs SC Config man page
  • YourServiceName is the actual service name of your application, not it's current DisplayName (unless, of course, they're identical)
  • If your DisplayName is more than one word, it needs to be wrapped in quotes
  • There must be no space between the word "displayName" and the equals sign
  • There must be one or more spaces between equals sign and the beginning of your desired service description
like image 39
STLDev Avatar answered Oct 20 '22 13:10

STLDev