Wait For Service To Stop in a Batch File

Sometimes in a batch file we need to wait until a service is stopped before we carry on processing our script.  NET STOP will only wait a finite amount of time for a service to stop, so for services that take a while to stop we can use a simple loop.  This is just an example of stopping the Adobe update service and waiting – just replace the service name as required:

@echo off

REM Run your command line here - probably: NET STOP AdobeARMservice 
REM Wait for Adobe Update service to stop
sc query AdobeARMservice | find "STOPPED" >nul 2>&1

  Timeout /T 5 /Nobreak
) ELSE (
REM Carry on with more logic


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.