Possible Duplicate:
How to sleep in a batch file?
Here's a haxxorish way to pause for a second in a batch file:
PING 400.500.600.700 > NUL
I've googled but I'm not sure there are any better ones.. any ideas? :)
Here's a haxxorish way to pause for a second in a batch file:
I've googled but I'm not sure there are any better ones.. any ideas? :) |
|||
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 use the "default choice" and "timeout" options of the built-in choice command to create a delay.
|
|||||||||||||||||||||
|
|
The correct way to do this is to use the To wait 30 seconds:
The timeout would get interrupted if the user hits any key; however, the command also accepts the optional switch
Additionally, if you don't want the command to print its countdown on the screen, you can redirect its output to
|
|||||||||||||||
|
Hitting a key will over ride the count down is the only downside. |
|||||
|
|
Apparently the windows resource kit has the sleep command in it. Other Sites also recommend using choice..... |
|||
|
|
|
Here's what I've been using as substitute for sleep.exe,
Change |
|||||||||||
|
|
CHOICE command with a timer on it works well... CHOICE /C:x /T:x,10 > NUL There are also "programs" out there you could run like WAIT and SLEEP, etc. Hope this helps. |
|||
|
|
|
The ping one (above) is a good one- but only works if connected to a network. A bit of script that will delay is below: @echo off set /a secondsend=%TIME:~6,2%+10 if %secondsend% GTR 59 set /a secondsend=secondsend-60 :waithere if %TIME:~6,2% NEQ %secondsend% goto waithere This will pause from between 9-10 seconds (the first second isn't accurate due to using the TIME command- and it could be halfway through a second before you begin). If works by setting 'secondsend' to the current second of the pc clock, then adding 10 to it (the delay). If it's greater than 59 taking 60 off as it's wrapped around to next minute. Then there is a loop which checks the current second with 'secondsend'- once they match the script continues. If you want to delay by a different period 2-59 then alter the 10 in the second line (I say 2-59 as the first second might not be a full second, so 2 could be say, 1.2 seconds for example). Sorry it's so longwinded but thought I'd explain how the routine works. |
|||||||
|
|
I just wrote a simple exe in C#. Simply using the statis System.Threading.Sleep, and take the commandline argument and convert it to an integer. It took 5 minutes to do. |
|||
|
|
pingcommand treats anything shorter than four digits as an acceptable IP octet... – Massimo Sep 26 '12 at 19:10