I want to check programmatically that the latest version of my Windows Service is installed. I have:
var ctl = ServiceController.GetServices().Where(s => s.ServiceName == "MyService").FirstOrDefault();
if (ctl != null) {
// now what?
}
I don’t see anything on the ServiceController interface that will tell me the version number. How do I do it?
I am afraid there is no way other than getting the executable path from the registry as
ServiceControllerdoes not provide that information.Here is a sample I had created before:
After getting the exe path, just use
FileVersionInfo.GetVersionInfo(exePath)class to get the version.