How to set delay in vbscript?
WScript.Sleep(100)
does not work on Windows XP, Vista.
You can use WScript. Echo to see exactly what VBScript passes out; if the string you see in the result of WScript. Echo works in a command-prompt window, it will work as the first argument for the Run method.
A script can force itself to pause by calling the WScript Sleep method. The Sleep method accepts a single parameter that indicates how long, in milliseconds, to pause the script. (There are 1,000 milliseconds in a second and 60,000 milliseconds in a minute.)
Work this end (XP).
Create a new file, call it test.vbs. Put this in it.
WScript.Sleep 1000 MsgBox "TEST"
Run it, notice the delay before the message box is shown.
Note, the number is in Milliseconds, so 1000 is 1 second.
If you're trying to simulate a sleep delay in VBScript but WScript is not available (eg: your script is called from Microsoft's BGInfo tool), then try the following approach.
The example below will delay until 10 seconds from the moment the instruction is processed:
Dim dteWait dteWait = DateAdd("s", 10, Now()) Do Until (Now() > dteWait) Loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With