views:

86

answers:

3

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
+2  A: 

check the following link:

Implementing the WAIT Command in a Batch File

Batch file SLEEP Command

Wael Dalloul
Hey, this approach is very clever :)
ATorras
+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
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
@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