Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Pause Batch Script for a Number of Seconds

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

burnettm's picture
27
Jun
2008
0 Votes 0
Login to vote

SFU

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

DustyPete's picture
27
Jun
2008
0 Votes 0
Login to vote

I typically use ping also,

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.

wuzfuzzy's picture
30
Jun
2008
0 Votes 0
Login to vote

Better to use the loop back address

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!

supaflash's picture
21
Aug
2008
1 Vote +1
Login to vote

New Syntax for Windows/PE

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

REM Wait 5 seconds
ping -n 5 127.0.0.1 > nul