如何延迟Vb脚本?以下代码对我不起作用:
wscript.sleep 1000
Delay 10
Sub Delay( seconds )
Dim wshShell, strCmd
Set wshShell = CreateObject( "Wscript.Shell" )
strCmd = "%COMSPEC% /C (PING -n " & ( seconds + 1 ) & " 127.0.0.1 >NUL 2>&1 || PING -n " & seconds & " ::1 >NUL 2>&1)"
wshShell.Run strCmd, 0, 1
Set wshShell = Nothing
End Sub
dim oshell
set oshell = CreateObject("Wscript.Shell")
obshell.run "%windir%\system32\rundll32.exe kernel32.dll Sleep 5000"
第一条语句,WScript.Sleep 1000
,做的工作。您的错误必须在其他地方。
证明
在桌面上创建文件test.vbs:
WScript.Echo Time()
WScript.Sleep 2000
WScript.Echo Time()
运行如下:
C:\Users\...\Desktop>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
11:31:34
11:31:36
请注意两个第二个区别。(如果此确切的脚本在您的PC上产生了不同的结果,请在评论中声明并接受我的道歉。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句