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 XP
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 XP
You can ping a random address and specify the desired timeout:
ping 123.45.67.89 -n 1 -w 10000 > nul
And since the address does not exists, it'll wait 10,000 ms (10 seconds) and returns.
-w 10000
part specifies the desired timeout in milliseconds.-n 1
part tells ping that it should only tries once (normally it'd try 4 times).> nul
part is appended so the ping command doesn't output anything to screen.You can easily make a sleep command yourself by creating a sleep.bat somewhere in your PATH and use the above technique:
rem SLEEP.BAT - sleeps by the supplied number of seconds
@ping 123.45.67.89 -n 1 -w %1000 > nul
...
Well, does sleep even exist on your 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.
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
this blog post has a number of ideas on how to best do this:
http://notetodogself.blogspot.com/2007/11/wait-in-windows-bat-script-good-way.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
Hi I decided to write sleep for my own. Check out my homepage http://www.marcindabrowski.net/?p=122