Batch and Powershell sleep commands

Sometimes when creating a script, you may need the script to wait or sleep for a certain period of time.

Batch Scripts:

If you search the interwebs, you will find a lot of workarounds that involve pinging a network address for a certain number of times. While this gets the job done, it isn’t necessarily the most straightforward way.

Luckily, there is another command that allows you to specify a wait time in seconds. This command is called timeout, which is something you are probably familiar with if you have kids. It does exactly what it sounds like, it sits there and waits for the number of seconds you specify. Or if you want the Microsoft definition: This utility accepts a timeout parameter to wait for the specified time period (in seconds) or until any key is pressed. It also accepts a parameter to ignore the key press.

According to Microsoft, the command applies To: Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Vista, Windows XP.

So I am curious why this isn’t more widely used.


Although you can use the same command with PowerShell, you may want to take advantage of a new command called Start-Sleep. The Start-Sleep cmdlet suspends the activity in a script or session for the specified period of time. You can use it for many tasks, such as waiting for an operation to complete or pausing before repeating an operation.

Find more on these commands here: