问题
I am writing a VBScript for an application that runs on an industrial controller which does not support WScript
. The controller has a single thread for processing VBScript and I need to pause my script for only a few program scans to allow another event handler to process. VBScript is processed in a WSH shell. If I run a MsgBox
and popup a message it frees the script to do what it needs to and everything works fine but I cannot have a message box popping up.
Everything I have read suggests using WScript.Sleep
but that is not available to me.
This does not run in a web browser so the window.timeout object is not available. I cannot access WScript.Sleep so that is not an option.
回答1:
If the granularity of seconds is fine enough for you and your operating system is Windows Vista or higher, you can take this script as a sample of how to wait for three seconds:
MsgBox (Now()), , "1"
WScript.CreateObject("WSCript.shell").Run "timeout.exe /T 3", 0, True
MsgBox (Now()), , "2"
来源:https://stackoverflow.com/questions/54487205/alternative-for-wscript-sleep-and-window-timeout