Halt batch file until service stop is complete?

batch-file, servicecontroller

Solution

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

See - NET stop

Problem

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?

Original source

Related problems