Pausing a batch file for amount of time [duplicate]
Possible Duplicates:
Sleeping in a DOS batch file How to wait in a batch script
I have a program that is kicked off with a batch file.
The first module takes 10 seconds or so to initialize, and I want a way to "sleep" for 15 seconds before the second module is called开发者_开发百科, but I don't want it to require the user to hit a key like "pause" seems to require.
So, this is what I mean:
echo %PATH%
pause 10
echo %PATH%
In this example, I want there to be 10 seconds in between the echos. Is this possible? I've seen some examples using "ping 1.1.1.1" but it doesn't seem to work all the time correctly.
ping -n 11 -w 1000 127.0.0.1 > nul
Update
Beginner's mistake. Ping doesn't wait 1000 ms before or after an request, but inbetween requests. So to wait 10 seconds, you'll have to do 11 pings to have 10 'gaps' of a second inbetween.
If choice
is available, use this:
choice /C X /T 10 /D X > nul
where /T 10
is the number of seconds to delay.
Note the syntax can vary depending on your Windows version, so use CHOICE /?
to be sure.
精彩评论