Possible Duplicate:
Sleeping in a DOS batch file
I am trying to write a batch script and trying to wait 10 seconds between 2 function calls.
sleep 10
does not wait for 10 seconds.
I am running Windows XP.
I am trying to write a batch script and trying to wait 10 seconds between 2 function calls.
does not wait for 10 seconds. I am running Windows XP. |
||||
add comment (requires an account with 50 reputation) |
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You can ping an address that surely doesn't exist and specify the desired timeout:
And since the address does not exists, it'll wait 10,000 ms (10 seconds) and returns.
You can easily make a sleep command yourself by creating a sleep.bat somewhere in your PATH and use the above technique:
NOTE: The 192.0.2.x address is reserved as per RFC 3330 so it definitely will not exist in the real world. Quoting from the spec:
|
|||||||||||||||||
|
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
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 |
|||||||||||
|
I used this
|
|||||||
|
The blog post "Wait in Windows bat script - good way" has a number of ideas on how to best do this. |
||||
|
What about:
|
||||
|
Well, does Chakrit's answer gives you another way to pause, too. Try running |
||||
|
set foo = bar
in batch, random being not random and other common mistakes. I think it's hopeless ;-) – Јοеу Feb 5 '11 at 19:46