Sleep command in Windows 7

by admin on April 18, 2012

There are two commands which we can use to make a batch command sleep for some time. The native available ‘timeout’ command and the resource kit tool ‘sleep’.

Timeout command

We can use ‘timeout’ command in Windows 7 to pause execution for some time and then continue. We can specify the number of seconds to wait, it would wait till the time elapses or until user presses any key.

Example: To wait for 10 seconds

c:\>timeout 10
Waiting for  10 seconds, press a key to continue ...

Example: To sleep for 2 minutes and ignore any key presses

c:\>timeout 120 /nobreak
Waiting for  120 seconds, press CTRL+C to quit ...

Sleep command

Windows provides a resource kit tool ‘sleep’ which can be used in batch files or command prompt to pause the execution and wait for some time.  Though the tool was intended for XP, I have used it on Windows 7 and it works perfectly fine. Find the download location and installation instructions here :Download Windows resource kit tools .

Syntax of sleep command:

sleep no_of_seconds_to_wait

(or)

sleep -m no_of_milli_seconds_to_wait

Examples:
If you want to pause the execution of a batch file for 50 seconds, then you should insert below statement in your batch file.

sleep 50

If you want to wait for 100 milli seconds, then you can run the below command.

sleep -m 100

Sleep command should also work find on Server 2008 and Server 2008 R2.

Also Read:Windows  commands

{ 4 comments… read them below or add one }

chris June 12, 2013 at 1:20 pm

Instead of downloading extra tools, you can stick with the ping command as well:
ping /t 50 localhost
will “sleep” 50 secs before going on

Reply

admin February 7, 2015 at 6:20 pm

Out of curiosity, I compared ping vs timeout and both seem to have stopped exactly at the same time. However, with the availability of timeout command, we don’t have to look for such alternatives.

chris June 12, 2013 at 1:24 pm

Excuse my typo. For 50 sec sleep, use

ping localhost -n 50

Reply

Erik August 1, 2013 at 8:42 pm

in Windows Vista an later, you can use Timeout /t

Reply

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: