If the binary isn't running under Service Control Manager (SCM), then StartServiceCtrlDispatcher() will fail with ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. This is a more reliable way of detecting if a service is running under SCM than checking svc.IsAnInteractiveSession. Checking the IsAnInteractiveSession value first can be an optimization to avoid skipping the StartServiceCtrlDispatcher error check.
If the binary isn't running under Service Control Manager (SCM), then
StartServiceCtrlDispatcher()
will fail withERROR_FAILED_SERVICE_CONTROLLER_CONNECT
. This is a more reliable way of detecting if a service is running under SCM than checkingsvc.IsAnInteractiveSession
. Checking theIsAnInteractiveSession
value first can be an optimization to avoid skipping theStartServiceCtrlDispatcher
error check.In Go,
svc.Run
should fail here callingwindows.StartServiceCtrlDispatcher
.Troubleshooting tips, if needed: http://stackoverflow.com/a/30719534 (from 2015-05-26)