Upon installation of a Windows Service, an application is using a custom action to set the ServiceName and DisplayName of that service according to whatever the user enters into an install dialog text box.
In testing this application it works fine for installation but when I try to uninstall the service I get an Error 1001. Service does not exist.

which is ultimately not true because I can run it. So my present thinking is that i need to somehow access the custom name of the service and feed that to the uninstaller. I would have thought this was all GUID based and that the name would become largely irrelevant re: uninstall but it would seem not to be the case.
So how to do I resolve this problem?
I will assume that your are using an
Installerderived class together with aServiceInstallerinstance.I do something similar in a project. The service name is stored inside a text file (this is just an option, but for me it’s there for automatic deployment purposes). You can store it anywhere (registry, etc).
So you should persist somewhere the custom service name configured during the install phase.
So, I have my
Installerclass:And in it’s constructor, I do:
Notice the
ServiceNameReader.GetServiceName()function. This custom function gets the service name from the file.The
Installerclass is instantiated and called during uninstallation too. So if you do something like this, to load the actual service name dynamically from somewhere, you will be able to uninstall it successfully.