Alternative for WScript.Sleep and window.timeout [duplicate]

和自甴很熟 提交于 2020-07-22 06:14:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!