Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is there a sleep function in wscript for vbscript?


Asked by Alaric Lim on Dec 14, 2021 VBScript



VBScript: Sleep function (or Wait for few minutes) WScript provides a function called Sleep. You can use sleep function to pause the script for specified milliseconds.
Consequently,
The VBScript's Sleep method suspends script execution for a specified length of time (in milliseconds), then continues execution. The Sleep method can be useful when you are running asynchronous operations, multiple processes, or if your script includes code triggered by an event.
In this manner, Syntax WScript.Sleep lngTimeArguments: lngTimeis the delay in milliseconds Sleep is a wscript method. Example WScript.Sleep(5000) WScript.Echo("5 seconds have passed.")
Thereof,
You will need to use the Sleep method in your scripts when: · Your script must wait for an event to occur before continuing to run. · You want your script to periodically check the status of a system parameter (for example, checking processor usage every 10 seconds).
Additionally,
I often need delays in my scripts, e.g. to wait for an object or a connection to get ready. The easiest way to implement a 1 second delay, of course, is WSH's WScript.Sleep 1000 (delay in milliseconds).