Batch Sleep

I’ve written a fair number of batch scripts in my day. Useful for fairly simple to moderately simple tasks in Windows, batch scripting usually works without any extras required.

I just found a trick that allows a script to have delay time between executed statements, without needing extra .exe’s. It uses the ping command which is found on every windows operating system.

@ECHO OFF
SETLOCAL

ECHO.Closing in 5 Seconds
ECHO .....
CALL :sleep 1
ECHO ....
CALL :sleep 1
ECHO ...
CALL :sleep 1
ECHO ..
CALL :sleep 1
ECHO .
CALL :sleep 1
ENDLOCAL
GOTO :EOF

:sleep
:: sleep for x number of seconds
ping 127.0.0.1 -n 2 -w 1000 > NUL
ping 127.0.0.1 -n %1 -w 1000 > NUL
GOTO :EOF

Hope you find this handy!

RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.