September 13, 2011
Ever wonder how to put a 20 second pause into a batch file on Windows? I had that problem today. I was setting up some virtual machines on a virtual machine hosting provider and needed a way to launch 2 virtual machines from a batch file. I knew that the Windows Server 2008 domain controller took 75 seconds to boot, and I didn’t want the member server to start until after the DC was completely up and running.
The command, PAUSE has been available to batch files forever, but it waits for an enduser to press a button before it continues. I want to just wait for a certain time interval. Well, it turns out there is another command available in Windows that does exactly what I needed. The command is TIMEOUT and I think it first showed up in Windows Vista. Add timeout /t 75 and your batch file will wait 75 seconds before it continues to the next step.