Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.
Endpoint Management Community Blog

Pause Batch Script for a Number of Seconds

Created: 26 Jun 2008 • Updated: 07 Jul 2009 • 4 comments
CondorMan's picture
+2 2 Votes
Login to vote

There are a few ways to have a batch script wait for a number of seconds. The simplest and most widely available without any additional programs is to use the ping command.

The following is is an example... PING!

ECHO Waiting 5 seconds
PING 1.1.1.1 -n 1 -w 5000 > NUL

Comments 4 CommentsJump to latest comment

burnettm's picture

You can also use the sleep command just like on *NIX boxes. You can get it from Microsoft Services for UNIX.

0
Login to vote
DustyPete's picture

I typically use ping also, even though it's a common batch hack. These days, I prefer relying on PowerShell instead of plain batch files though.

0
Login to vote
wuzfuzzy's picture

You should use the loop back address versus a non existing ip
ECHO Waiting 5 seconds
PING 127.0.0.1 -n 1 -w 5000 > NUL

Your method for a timer is nice since it doesn't use any "Special" commands or require additional software to be loaded like powershell.

Lee Wilburn
Suzlon Wind Energy
If your question has been resolved, please click "Mark as Solution"! Thank you. Hope it helps!

0
Login to vote
supaflash's picture

I found that the syntax is different in Windows based DOS.

REM Wait 5 seconds
ping -n 5 127.0.0.1 > nul

+1
Login to vote