How to create a delay in a batch file

Updated: 08/31/2020 by Computer Hope
Batch file

Below is an example of how to delay a batch file. Because there is no delay or sleep option included with MS-DOS or Windows, we are using the choice command to implement a delay.

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. To increase or decrease this time, change the "5" to a different value.

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

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. 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 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 want using this utility.