computer help index
 
 
Search:
"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,360 tips!

Windows XP and DOS

Batch file SLEEP Command

SUMMARY: Cause Windows XP batch files to sleep for a given number of seconds.

Most operating systems provide a command in batch files to sleep, or wait, a certain number of seconds. This is great in that batch files can display text, allowing you time to read before continuing. Or, batch files may wait a few seconds in order to connect to other resources.

While Windows XP does not come with such a command, there are tricks to emulate it, such as a 'ping' command trick to emulate the sleep command. However, if you wish, the Windows 2003 Resource Kit provides a 'sleep' command requiring no extra tricks. The Resource Kit is a large download, but besides the 'sleep' command, the Windows 2003 Resource Kit also provides tools to remap keys, query the Active Directory, display the last 'n' lines of a text file (a tail command), and more. To download and install the Resource Kit:

1. Go to the Microsoft Windows Server 2003 download section at http://www.microsoft.com/windowsserver2003/
downloads/tools/default.mspx
. Or, if that link does not work, visit http://www.microsoft.com/ and search for "Windows 2003". Once there, choose the "Downloads -> Tools" link.

2. Select the link "Windows Server 2003 Resource Kit Tools".

3. Click the "Download" link. Choose to register or not, depending on your choice, and follow the on-screen instructions to download and install the product. The default install directory is "C:\Program Files\Windows Resource Kits\Tools\".

Once the Windows 2003 Resource Kit is installed, you may need to reboot your machine for the directory "C:\Program Files\Windows Resource Kits\Tools\" to be added to your path.

Now that the sleep command is available, to see the online help, enter the following DOS command:

C:\>sleep /?

Or, just issue the command:

C:\>sleep N

Replace N with the number of seconds for batch file to 'sleep'. For example, a batch file can wait 5 seconds before continuing by issuing this command:

C:\>sleep 5

If you need to wait just a few milliseconds, issue this command:

C:\>sleep -m N

So, to sleep half a second:

C:\>sleep -m 500

Although this command supports a 'precise' millisecond sleep, I would not recommend it for real-time processing!

 

 
Add: Del.icio.us | Digg | Furl | My Yahoo!
 

Discuss This Tip

Print This Tip

Get E-Mail When New Tips are Online

Return to the Windows XP and DOS page.


More in MalekTips:
Internet Explorer 7 MiscWindows Vista - ExplorerGoogle Image Search



Change Cache SizeCopy File or Folder Path to DOS Prompt or Windows AppSearch for Images in Various Sizes

RSS Feeds - Subscribe!
 

You want the latest tech tips and tricks in your e-mail Inbox - FREE? Type your e-mail address below and click 'Subscribe'.
 



( sample / details ) ( opt-out instructions )
 


 Free Offer! - Subscribe to the MalekTips computer help list and be one of the first to get new computer tips, articles, and download links! ( privacy policy )  ( opt-out instructions )
This page and its contents are copyright
©1997 - 2008 Envision Programming. ( copyright/disclaimer )

Home | Free Computer Help Newsletter! | Windows | Web Development | DOS and Batch Files | Removing Spyware
Digital Camera and Photography | Computer and Internet | Software | Microsoft Word
Computer Articles | About | Contribute a Tip | Link To Us! | Computer and Technology Links
RSS Feeds |  Contact Us | Advertising | Privacy Policy | Computer Help Forums