I want to run some command once, 10 seconds to 1 minute from now.

Windows at command only receives absolute times, like 11:50.

How can it be done? Can it be done with other command line means?


Yes, the timeout command can handle that:

timeout /t 10 >NUL
echo "this message will be echoed after 10 seconds timeout"


timeout /t 10 >NUL && echo "this message will be echoed after 10 seconds timeout"

For more information, see timeout /?. The use of >NUL is to avoid it showing timeout on the screen, feel free to remove it.

If timeout not available on your system, you could also use ping -n 10 >NUL instead of timeout /t 10 >NUL as described here.

| improve this answer | |
  • 1
    Windows 7 doesn't seem to have that command either. The correct command is timeout. Also, typically Windows uses /?, or sometimes -?. Linux is more likely to use --help. – Bob Mar 11 '12 at 10:23
  • You are right, my mistake, looks like I've installed some 3rd party tools includes the sleep command and it requires an --help argument. – Mengdi Gao Mar 11 '12 at 10:28

On Xp I used a seperate sleep executable came in some microsoft package , worked in seconds. Sleep 1

In windows 7 , I switched and started using timeout /T 1 > NUL With the 1 representing the ammount of seconds. Timeout /? for the help on it.
Without the redirection of the output timeout 10 it shows an abortable countdown, which has other uses.

It was always important to me to find the one that required minimal resources, both of these methods seem to require very little effort for the computer.

| improve this answer | |
  • The advantage of the sleep executable is it's easy to use. The disadvantage, and worth noting, is it's not very portable. If this command needed to be deployed on a large number of computers, or needed to be used on a computer set to disable unregistered executables (yes, group policy can do that), a separate executable is not desired. – Bob Mar 11 '12 at 10:39
  • ^ so true, I also dont plop loose items into the pile of system junk already there, or change systems paths, so I had to use full path. Any cool batches that I made were often parts&pieces , and not very useful to another user. – Psycogeek Mar 11 '12 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.