Vbscript 执行时显示消息对话框

Vbscript 执行时显示消息对话框,vbscript,wsh,Vbscript,Wsh,我在vbscript中使用此代码段: Set WSH = CreateObject("WScript.Shell") cmd = "some command" flag = WSH.Run(cmd, 0, true) 可以注意到,在.Run()调用中,“WaitOnReturn”被设置为“true”,因为我想知道外部程序何时完成以及它的状态 问题是,外部程序需要一些时间来完成,我想弹出“请稍候…”MsgBox,但我不能这样做,因为我将“WaitOnReturn”设置为“true”,我需要它,因

我在vbscript中使用此代码段:

Set WSH = CreateObject("WScript.Shell")
cmd = "some command"
flag = WSH.Run(cmd, 0, true)
可以注意到,在
.Run()
调用中,“WaitOnReturn”被设置为“true”,因为我想知道外部程序何时完成以及它的状态

问题是,外部程序需要一些时间来完成,我想弹出“请稍候…”MsgBox,但我不能这样做,因为我将“WaitOnReturn”设置为“true”,我需要它,因为我需要该程序的结果进行额外处理


有什么方法可以在执行外部程序时以某种方式显示此MsgBox吗?

对不起,我无意中知道,我可以在执行之前调用MsgBox,Run() :尴尬:


编辑:

对于无用户交互,这里有一个解决方法(取自)

然后用以下词语来称呼它:

ProgressMsg“正在安装,请稍候”,“一些标题”

以以下方式结束:


ProgressMsg“,“一些标题”

我在另一个博客上得到了答案,基本上,我所要做的就是在全局范围内调暗变量“ProgressMsg”


谢谢

不用不好意思,我们都有疏忽。我曾考虑过向您指出这一点,但我认为您不想依赖于在启动命令之前单击MsgBox。
Function ProgressMsg( strMessage, strWindowTitle )
' Written by Denis St-Pierre
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    strTEMP = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
    If strMessage = "" Then
        On Error Resume Next
        objProgressMsg.Terminate( )
        On Error Goto 0
        Exit Function
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strTempVBS = strTEMP + "\" & "Message.vbs"

    Set objTempMessage = objFSO.CreateTextFile( strTempVBS, True )
    objTempMessage.WriteLine( "MsgBox""" & strMessage & """, 4096, """ & strWindowTitle & """" )
    objTempMessage.Close

    On Error Resume Next
    objProgressMsg.Terminate( )
    On Error Goto 0

    Set objProgressMsg = WshShell.Exec( "%windir%\system32\wscript.exe " & strTempVBS )

    Set wshShell = Nothing
    Set objFSO   = Nothing
End Function