【问题标题】:Creating a Message Box that runs a Specified Program (vbs)创建运行指定程序 (vbs) 的消息框
【发布时间】:2015-02-17 02:17:53
【问题描述】:

使用我拥有的以下脚本:

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

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

基本上,由于它会弹出一个是/否消息框,我只需让“是”按钮执行指定的批处理文件。我真的可以使用一些帮助来找出问题所在。当我尝试上面列出的代码时,选择是时没有任何反应(除了对话框消失)。

【问题讨论】:

  • 第一行使用"x=",但第二行使用"box"。

标签: batch-file vbscript msgbox


【解决方案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
'***************************************

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多