I have a script like this:
@start /b cmd /c net stop "Service"
@start /b cmd /c net stop "Service"
@start /b cmd /c net stop "Service"
@start /b cmd /c net stop "Service"
@start /b cmd /c net stop "Service"
pause
However, the pause
command gets executed before all of the lines above it in the script have been executed. I need to use @start /b cmd /c
so that it doesn't have to wait for the "Stopping Service..." after each service (about 100) of time. Is there any way to tell cmd to wait until all of the @start /b cmd /c net stop "Service"
commands have completed then run the pause?
To see what I'm talking about run this batch file:
@start /b cmd /c echo Hello
@start /b cmd /c echo Hello
@start /b cmd /c echo Hello
@start /b cmd /c echo Hello
@start /b cmd /c echo Hello
@start /b cmd /c echo Hello
pause
Instead of the Pause
occurring after all of the Hello
have been printed, it happens in the middle:
timeout 1 /nobreak >nul
before your pause. This may need tuning depending on what services your stopping or if they can cause issues, but at least for your example the invisible one second delay seemed to do the trick.