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.
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.
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:
SC config
command can be found here: MS Docs SC Config man page
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