I am trying to write a batch script and trying to wait 10 seconds between 2 function calls. The command:
sleep 10
Does not make the batch file wait for 10 seconds.
I am running Windows XP.
Note: This is not a complete duplicate of Sleeping in a batch file as the other question is about also about python, while this is about windows batch files.
This question is related to
batch-file
Well, does sleep
even exist on your Windows XP box? According to this post: http://malektips.com/xp_dos_0002.html sleep
isn't available on Windows XP, and you have to download the Windows 2003 Resource Kit in order to get it.
Chakrit's answer gives you another way to pause, too.
Try running sleep 10
from a command prompt.
I used this
:top
cls
type G:\empty.txt
type I:\empty.txt
timeout /T 500
goto top
You'd better ping 127.0.0.1. Windows ping pauses for one second between pings so you if you want to sleep for 10 seconds, use
ping -n 11 127.0.0.1 > nul
This way you don't need to worry about unexpected early returns (say, there's no default route and the 123.45.67.89 is instantly known to be unreachable.)
I actually found the right command to use.. its called timeout: http://www.ss64.com/nt/timeout.html
What about:
@echo off
set wait=%1
echo waiting %wait% s
echo wscript.sleep %wait%000 > wait.vbs
wscript.exe wait.vbs
del wait.vbs
Source: Stackoverflow.com