Export (0) Print
Expand All
Expand Minimize

Converting the Windows Script Host Sleep Method


Windows PowerShell


Definition: Suspends script execution for a specified length of time, then continues execution.

Sleep


WSH’s sleep method enables you to pause a script for a specified amount of time; PowerShell’s Start-Sleep cmdlet lets you do the very same thing. However, Start-Sleep does have one advantage over the Sleep method. When working with the Sleep method you must specify the sleep time in milliseconds; to pause a script for 5 minutes you must use code like this, with the 300000 representing 300 seconds (5 minutes):


Wscript.Sleep 300000


By contrast, Start-Sleep lets you specify the sleep time in seconds; in other words, Start-Sleep lets you use a command like this one:


Start-Sleep 300


Of course, if you really, truly need to specify sleep times down to the millisecond you can always tack on the -milliseconds parameter:


Start-Sleep -milliseconds 300000


It’s entirely up to you.


See conversions of other Windows Script Host methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft