Halt batch file until service stop is complete?

lance picture lance · May 20, 2010 · Viewed 56.1k times · Source

I'm using a batch file to stop a Windows service. I'm using the sc command, but I'm open to other ideas, given the question below. The problem is that the batch file proceeds while the service is stopping (the stop argument to sc seems only to request the stop -- it doesn't wait for the stop).

How can I modify the batch file to not proceed until the stop is complete?

Answer

mdma picture mdma · May 20, 2010

You can use NET stop, which is synchronous, i.e it will wait until the service stops.

See - NET stop