Clever way of waiting for a specified delay in a DOS / Windows batch file...
Published Wed, 23 Jan 2013 • 2 comments
Here's an interesting little tip. If you ever find yourself in the (unfortunate) position of having to write a DOS / Windows batch file, and need to "wait for 10 seconds" or some period of time, you'll find there isn't built in command for this.
However, you can use this nifty little hack to cause a delay:
ping 0.0.0.0 -n 10 > nul
Increase or decrease the
-n 10 for more or less delay.
This causes ping to send
n packets to an unresolvable address, which will always cause a delay.
About the Author
Richard Nichols is an Australian software engineer with a passion for making things.
You might also enjoy reading -
- Use Hudson (now Jenkins) to restart a Windows service...
- MHTML Browser Compatibility - CSS Inlining
- eBooks + DRM = Fail
- Quick Tip - Make Anything A Windows Service
- Setting Up Memcached As A Windows Service