How I can make wait x sec in console (cmd), without "timeout" command?
+2
A:
You need an external tool; the standard CMD.EXE can't do this. The most simple solution is probably sleep.exe
from any Resource Kit.
Aaron Digulla
2009-08-20 08:26:26
Hey, this approach is very clever :)
ATorras
2009-08-20 08:30:17
+1
A:
You can use ping:
ping 127.0.0.1 -n 11 -w 1000 >nul: 2>nul:
will wait 10 seconds.
The reason you have to use 11 is because the first ping goes out immediately, not after one second. The number should always be one more than the number of seconds you want to wait.
paxdiablo
2009-08-20 08:28:55
it is not recommended to use this for critical real-time processing.because PING command is being used, it is possible that this WAIT batch file may run over a few milliseconds
Wael Dalloul
2009-08-20 08:31:46
@Wael, if you're talking about waiting on one-second boundaries, a few milliseconds will be irrelevant. And if you're using cmd.exe for realtime stuff, you deserve everything you get :-)
paxdiablo
2009-08-20 08:34:01