Alex Rivera | Logout

Windows batch: sleep

Asked 2010-11-30T18:14:52.587
135

How do I get a Windows batch script to wait a few seconds?

sleep and wait don't seem to work (unrecognized command).

Edit
Report

2 Answers

174
timeout /t 10 /nobreak > NUL

/t specifies the time to wait in seconds

/nobreak won't interrupt the timeout if you press a key (except CTRL-C)

> NUL will suppress the output of the command

answered 2010-11-30T18:26:47.997
1

Personally I use a Perl one-liner:

perl -e "sleep 10;"

for a 10-second wait. Chances are you'll already have Perl installed on a development machine as part of your git installation; if not you will have to install it, for example, from ActiveState or Strawberry, but it's one of those things I install anyway.

Alternatively, you can install a sleep command from GnuWin32.

answered 2010-11-30T18:17:54.517

Your Answer