I am having a strange problem attempting to stop a service in a batch file and I'm wondering if there is a way to get more detailed information on the problem, or if someone knows why it might be occurring. First, this is running on Windows Server 2008 R2 Standard.
We have a Windows Service that occasionally needs to be stopped and then restarted, while updates are performed. We have been doing this through the UI, where a person would click on the service and then "Stop" it with the button. This has been done hundreds of times and the service has never failed to stop, or start successfully.
In an attempt to automate this, I created a batch file that I could then schedule to run as needed. When testing this, I have found that roughly 1 out of 3 times, when the "net stop" command is issued, it returns a message that the service could not be stopped.
As the "net stop" command has no options, I am not sure what else I could do. The stranger thing is, when this message happens, if I then go to the UI, the service appears as not running, as if the stop was successful. Furthermore, if I then either issue a "net start" command, or click on the Start button in the UI, the service says it starts successfully and everything appears to functioning as normal.
So, it's as if this error message about failing to stop the service is not correct and the service did in fact stop without error. I think it might be a matter of the service taking longer to stop that the net command is willing to wait. But as the "net stop" command has no options, there doesn't appear to be a way to have it wait longer. I could just ignore it, since everything is working as expected, but it bothers me that this message is being returned.
My first question would be, is there a more detailed error log somewhere associated with the message that is displayed in the command window that I could see what exactly it thinks failed? And second, has anyone else ever seen this happen, and either have a recommendation, either to fix it or that I should just ignore it.