How can I pause an execution of a script from within? Something like Sleep WinAPI function?
A:
You can use a WScript
object and call the Sleep
method on it:
Set WScript = CreateObject("WScript.Shell")
WScript.Sleep 2000 'Sleeps for 2 seconds
Another option is to import and use the WinAPI function directly (only works in VBA, thanks @Helen):
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sleep 2000
Oded
2010-10-27 20:04:57
Note: You can't run WinAPI functions from VBScript. Your second example works only in VB/VBA.
Helen
2010-10-27 20:21:21
@Helen - thanks for the information. Didn't know about this limitation. Answer updated.
Oded
2010-10-27 20:24:12