I have a Windows Service installed on a machine.
In a new release, I’ve renamed the services .exe name (e.g., MyService.exe -> Foo.Server.exe).
I understand service executable paths can be changed by modifying the registry, but does a managed API exist so that I can be more confident it won’t break in future releases?
You can PInvoke the SCM API, ChangeServiceConfig, and provide the lpBinaryPathName parameter.
Here is the PInvoke prototype from: http://pinvoke.net/default.aspx/advapi32/ChangeServiceConfig.html
Using the ServiceController class to open the SCM and service you just call it like this: