创建运行指定程序的消息框(vbs)

时间:2015-02-17 02:17:53

标签: batch-file vbscript msgbox

采取我的以下脚本:

x=msgbox ("Do you want to recycle the Premiere Pro Media Cache?" ,4, "Recycle Premiere Pro Media Cache")

If box =6 Then
CreateObject("wscript.shell").run "C:\Expedited\Scripts\PrMCRecycler1"
End If

我的目标是在按下yes按钮时获取此VBS文件(显示一个消息框)以运行批处理文件(与双击时运行的方式相同)。我不确定上面我做错了什么。当我单击否时,不需要发生任何事情,所以我没有为它指定任何内容。

基本上,因为它会显示一个是/否消息框,我只需要让yes按钮执行指定的批处理文件。我真的可以用一些帮助来弄清楚什么是错的。当我尝试上面列出的代码时,选择是没有任何反应(除了对话框消失)。

1 个答案:

答案 0 :(得分:1)

尝试此示例并更改批处理文件的路径。

Option Explicit
Dim ws,Question,PathProgram
Set ws = CreateObject("wscript.shell")
'change the path of your batch file
PathProgram = "C:\Program Files\Internet Explorer\iexplore.exe"
Question = Msgbox("Do you want to recycle the Premiere Pro Media Cache?",VbYesNO + VbQuestion, "Recycle Premiere Pro Media Cache")
If Question = VbYes Then
     ws.run DblQuote(PathProgram)
End If
'***************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'***************************************
相关问题