我正在尝试运行 VBScript 检查时间,直到到达 22:00(晚上 10 点),然后运行shutdown.bat
。我总是收到诸如“'loop' without 'do'”之类的错误。任何人都可以查看我的代码并看看是否有办法修复它?
Do
If Hour(Time()) => 22 And Minute(Time()) => 30 And Hour(Time()) < 23 Then
Loop Until True
Then
'Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run "shutdown.bat"
Set shell = Nothing
End If
如果您确实想保持循环运行直到达到特定时间,请按以下步骤操作:
Do While True ' = Do the following forever (or until something breaks the loop)
If Hour(Time()) => 22 And Minute(Time()) => 30 And Hour(Time()) < 23 Then
' Do whatever you want and then
' break the loop:
Exit Do
End If
Loop
但是,我不建议这样做,因为它会消耗大量资源。相反,你应该使用任务调度程序.
希望有帮助:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)