Blog About Contact

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.

Nice!


About the Author

Richard Nichols is an Australian software engineer with a passion for making things.

Follow him on twitter or subscribe by RSS or email.

You might also enjoy reading -


Discuss / Comment

There are 2 comments.

Add a comment

  • {{e.error}}

Thanks for your comment!/

Required.
Valid email address required.
Required.
Posting message, please wait...