Is the Sleep operation no longer used in VBscript?

后端 未结 3 1601
清歌不尽
清歌不尽 2020-12-02 01:14

The \"Sleep\" command as stated in many places over the internet (including here on this forum) DOES NOT WORK. Is it now an obsolete command?

I am writing the VBScri

3条回答
  •  情深已故
    2020-12-02 01:18

    Another option would be to (ab)use ping (if you want to avoid an additional script):

    Sub Sleep(seconds)
      CreateObject("WScript.Shell").Run "%COMSPEC% /c ping 127.0.0.1 -n " _
        & seconds+1, 0, True
    End Sub
    

    ping sends echo requests in (roughly) 1 second intervals, so you can get an n-second delay by sending n+1 echo requests.

提交回复
热议问题