How do I make a batch file wait / sleep for some seconds?
You can use the timeout
command:
This utility accepts a timeout parameter to wait for the specified time period (in seconds) or until any key is pressed. It also accepts a parameter to ignore the key press.
For example, to wait for 10 seconds:
TIMEOUT /T 10
For more details:
TIMEOUT /?
There are many sleep utilities you can download and drop into your System32 folder, one is provided with the Windows Server 2003 Resource Kit called sleep.exe
.
You can also use the ping trick:
:sleep
ping 127.0.0.1 -n 2 -w 1000 > NUL
ping 127.0.0.1 -n %1 -w 1000 > NUL
then from somewhere in your batch file, you can call it like so:
CALL :sleep 1
timeout /t <seconds> /nobreak > NUL