Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause and continue Batch file

Status
Not open for further replies.

jdam

IS-IT--Management
Jan 19, 2005
104
CA
Hi

I have a batch file that needs to pause for 10 seconds part way through, then continue. PAUSE command prompts for keystroke. I would like a pause like batch command to wait for 10 seconds before continuing with the rest of the commands.

ANy suggestions.
 
The Windows 2003 resource kit contains the "Sleep" command you can use. This is a free download:
In the alternative:

Do you need a batch file that waits a certain amount of seconds? In some languages, the command would be WAIT, but DOS and Windows do not come with this command for batch files. If you want to implement the WAIT command, create the following batch file and name it WAIT.BAT.

In your batch file, the wait (e.g. 10 seconds) is implemented with a CALL to WAIT.BAT:

CALL WAIT 10

If you are running Windows NT, Windows 2000, or Windows XP, you can use the following as WAIT.BAT:

@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000> nul

The reason for the two lines is that in order to wait using the PING command, you must add extra pings to correctly wait the desired number of seconds. Also, since the PING command is being used, it is possible that this WAIT batch file may run over a few milliseconds. Thus, it is not recommended to use this for critical real-time processing.
 
You thought about using wsh instead of batch files?

the WScript.sleep 1000 command would pause for a second.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top