Monday, July 17, 2017

Set Windows Service Description

This is a quick follow-up to the previous post about creating MSI installers for Windows Services.

The previous post describes how to add rows to two tables in an MSI database to promote the installer to formally manage the stop, start and deletion of registered services. Unfortunately, it's not possible to set the description of the service by editing the MSI database.

To change a service description (not the name or display name), you have to call into native functions in advapi32.dll which contains service controller functionality. You can find some online articles and samples of how to do this from managed C# code, but many of them are erroneous or questionable. I have determined the minimum correct C# code needed on Windows 10 to change a service description. The source file is here (as a txt file):

http://www.orthogonal.com.au/computers/MsiUpdater-ServiceEditor.cs.txt

NOTE: A follow-up experiment a few days later confirms that you can add a CA class to your setup project which calls the code above in the Install override to set the service description. Luckily, Visual Studio set the CA to run in the install sequence after the service processing.

No comments:

Post a Comment