Tip
Subject Content

82
Make a batch file snooze with Sleep.exe

Sometimes it's necessary to make a batch file pause to wait for user input, display information to

the user, or for some other reason. The PAUSE command works fine when you want to simply

pause execution of the batch file. It displays the message "Press any key to continue." When the

user presses a key, execution resumes.



In some cases, you'll probably want the batch file to pause for a specified period of time and then

continue on its own. For example, maybe you want to display a message to users for a brief period

during logon and then have the batch file continue automatically. You can do this by using the

Sleep.exe tool included with the Windows 2000 Resource Kit.



Sleep.exe takes only one parameter--the number of seconds to pause before continuing. The

following example would pause execution for 30 seconds:



sleep 30



Sleep is just half of the solution if you want to display a message. You also need to use ECHO to

display the message. So, issue as many ECHO commands as you need to display the message, then

follow those commands with a SLEEP command.

Page 82 of 237
First Previous Next Last