I have a Windows service program written many year ago and the user asked me to fix an issue that occurs recently in Windows 2008 R2. Indeed it is not a big problem but quite annoying. When the user stops the service, Windows always popup a window showing an error message like “Windows could not stop the […] service on local computer, The service did not return an error.” Damn it! How could you show me an error dialog with no error message?
Google doesn’t have any similar case like this. So I have try this and that, here and there.
OK, everybody knows that kind of experiments are boring and time consuming. So I just expose the answer.
In the service’s control handler codes for SERVICE_CONTROL_STOP, I reported a SERVICE_RUNNING status followed by a SERVICE_STOP status. That works without any problem before, but caused the issue in recent 2008 R2. After I changed the first status reporting to SERVICE_STOP_PENDING, the dialog disappears.
It looks like Windows doesn’t accept SERVICE_RUNNING when it sent to services SERVICE_CONTROL_STOP. But can you show me a clear error message?