它使您能够在下一次按下按钮之前退出。
要结束按需脚本并让其他脚本在后台运行,您需要另一个解决方案,最多是一个不同的程序,它为您提供一个可以停止它的小界面。或专门结束您的第一个脚本的第二个脚本。
Set Wshell=CreateObject("Wscript.shell")
Do
Wshell.SendKeys "{SCROLLLOCK}"
continue = MsgBox ("Do you want to press the ScrollLock again?", vbYesNo, "Question")
Select Case continue
Case vbNo
Exit Do
End Select
WScript.sleep 10000
Loop
取自这篇文章:How to stop a vb script running in windows
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "taskkill /f /im Cscript.exe", , True
WshShell.Run "taskkill /f /im wscript.exe", , True
还有第二个脚本可以以艰难的方式杀死您的脚本。我不知道你会如何想象停止脚本?如果没有 GUI,您将无法在您希望的时间执行此操作。要结合解决方案,您可以执行以下操作:
continue = MsgBox ("Do you want to press the ScrollLock again?", vbYesNo, "Question")
Select Case continue
Case vbNo
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "taskkill /f /im Cscript.exe", , True
WshShell.Run "taskkill /f /im wscript.exe", , True
End Select
然后将这个弹出的 MsgBox 拉到屏幕的角落,所以如果你不再想要它,只需按“否”就可以了。 ^^