The Computer Oracle

How do I make a batch file wait / sleep for some seconds?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi

--

Chapters
00:00 Question
00:40 Accepted answer (Score 33)
01:08 Answer 2 (Score 147)
01:44 Answer 3 (Score 10)
01:53 Answer 4 (Score 7)
02:13 Thank you

--

Full question
https://superuser.com/questions/48231/ho...

Accepted answer links:
[Windows Server 2003 Resource Kit]: http://www.microsoft.com/Downloads/detai...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows7 #windows #batch #sleep

#avk47



ANSWER 1

Score 163


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 /?



ACCEPTED ANSWER

Score 34


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



ANSWER 3

Score 11


timeout /t <seconds> /nobreak > NUL



ANSWER 4

Score 2


sleep.exe is included in the Windows Server 2003 Resource Kit Tools.

You may use:

sleep /?
sleep seconds
sleep -m milliseconds