按下按钮时脚本关闭

时间:2016-12-09 01:44:40

标签: vbscript

我正在使用VBScript进行编程,我只是抓住了ReturnValue = MsgBox("Content", 36, "Title"),我想按下按钮关闭我的代码,但是当你按下时打开一个应用程序按钮。

到目前为止,这是代码:

ReturnValue = MsgBox("Content", 36, "Title")
If ReturnValue = 7 Then
  Set WSHShell = WScript.CreateObject("WScript.Shell")
  WSHShell.run "open this.exe"
End If

If ReturnValue = 6 Then
  WScript.Quit
End If

1 个答案:

答案 0 :(得分:0)

您的脚本似乎正常工作。这里只需稍作修改即可使功能更加明显:

ReturnValue = MsgBox("Click yes to exit." + vbCrlf + "Click no to open Notepad.", 36, "Exit Script?")
If ReturnValue = 7 Then
   Set WSHShell = WScript.CreateObject("WScript.Shell")
   WSHShell.run "notepad.exe"
End If

If ReturnValue = 6 Then
    MsgBox "Script is now exiting"
    WScript.Quit
End If

如果您遇到其他行为,请告诉我们它是什么。

以下是MsgBox命令的完整文档:http://ss64.com/vb/msgbox.html