How to create a delay in a batch file

Updated: 04/26/2017 by Computer Hope

Batch fileBelow is an example of how to delay a batch file. Because there is no delay or sleep option included with MS-DOS or any version of Windows we are using the choice command to trick the batch file into delaying.

Choice in Windows Vista, 7, 8, and 10

Using the choice command included with these versions of Windows you can delay a batch file anywhere from 0 to 9999 seconds. In this example, we illustrate a five-second delay. If you want to increase or decrease this time change the "5" to a different value.

CHOICE /N /C YN /T 5 /D Y >NUL

  • See our choice command page for further information about each of these options.

Using choice in Windows XP and earlier and MS-DOS

Using the choice command included with Windows XP and earlier you can delay a batch file anywhere from 0 to 99 seconds. In this example, we illustrate a five-second delay. If you want to increase or decrease this time change the "5" to a different value.

Type NUL | CHOICE.COM /N /CY /TY,5 >NUL

  • See our choice command page for further information about each of these options.

Third-party sleep utility

Additionally, you could use the sleep file found on our utility downloads section. Once the sleep file is download you can sleep for as many seconds as you'd like using this utility.