循环播放VBScript [英] Looping VBScript
本文介绍了循环播放VBScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行VBScript,检查直到达到22:00(10PM)的时间,然后运行 shutdown.bat
.我总是会收到诸如循环"而不执行"之类的错误.谁能看我的代码,看看是否有办法解决它?
I'm trying to run a VBScript checking the time until it reaches 22:00 (10PM), and then runs shutdown.bat
. I always get errors such as "'loop' without 'do'". Can anyone look at my code and see if there's a way to fix it?
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
推荐答案
如果您真的想让循环一直运行到特定时间,请执行以下操作:
If you really want to keep a loop running until it reaches a specific hour, here's how it's done:
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
但是,我不建议这样做,因为它会消耗大量资源.相反,您应该使用任务计划程序.
However, I wouldn't recommend that because it will consume much resources. Instead, you should be using Task Scheduler.
希望有帮助:)
这篇关于循环播放VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文