Page Actions
Wiki Actions
User Actions
Submit This Story

Sleep() in windows batch

Need a sleep() in Windows Batch? Here are the ways…

1. ping yourself!

SET SLEEP=ping 127.0.0.1 -n
%SLEEP% 11 > nul

2. awesome TIME calculation

@ECHO OFF
SETLOCAL EnableExtensions
CALL :ProcDelay 200
ECHO %TIME%
GOTO :EOF

:ProcDelay delayMSec_
SETLOCAL EnableExtensions
FOR /f "tokens=1-4 delims=:. " %%h IN ("%TIME%") DO SET start_=%%h%%i%%j%%k
    :_procwaitloop
    FOR /f "tokens=1-4 delims=:. " %%h IN ("%TIME%") DO SET now_=%%h%%i%%j%%k
    SET /a diff_=%now_%-%start_%
IF %diff_% LSS %1 GOTO _procwaitloop
ENDLOCAL & GOTO :EOF
:EOF

Awesome calculating… Forgot where I got it…

3. windows2003 now provide "timeout" command.

Discussion

Enter your comment
 
 
blog/2009/10/sleep_in_windows_batch.txt · Last modified: 2009/10/01 00:00 (external edit)     Back to top
Recent changes RSS feed Creative Commons License Powered by PHP Driven by DokuWiki