Create your own sleep / wait program
1 January 2001 by Snakefoot | Comment » | Trackback OffIt can be useful in batch files to have the ability to perform a wait operation for a certain time period. Ex. if polling for a certain event (like a file being created by another program), or if having to perform an action with a certain period of time in between. There is no sleep or wait operation available in DOS, but you can create your own version.
CHOICE can be used where one specifies that it should pick the default after a certain period of time. Create a batch file WAIT.BAT with the following lines:
CHOICE can be used where one specifies that it should pick the default after a certain period of time. Create a batch file WAIT.BAT with the following lines:
If not having CHOICE available, but have TCPIP PING then one can use this instead:@REM The > NUL make sure that the screen output from choice is not shown
@CHOICE /T:N,%1% > NUL
To use WAIT.BAT, call it like this:@REM The > NUL make sure that the screen output from choice is not shown
@PING 1.0.0.0 -n %1 -w 10 > NUL
CALL WAIT 10
Updated: 23 September 2007