启动VBS MsgBox,但继续执行脚本

时间:2019-03-01 18:26:12

标签: batch-file

我尝试了多种不同的方法来实现以下目的,但找不到解决方法。我有一个ROBOCOPY脚本,该脚本根据退出代码输出VBS消息框。但是,我希望批处理脚本继续运行并甚至在出现消息框后退出。截至目前,我必须单击Ok以关闭VBS消息框,然后关闭命令行。

这是我的代码:

@ECHO OFF

::Delete DB File
CD "C:\Program Files (x86)\SAP\Agentry Client"
DEL "Agentry.db"
CLS

::Copy new DB file from Fil003
2>nul PUSHD "\\sampleserver\123\123" >nul

ROBOCOPY /ZB /IS /IT /R:3 "\\sampleserver\123\123" "C:\Program Files (x86)\SP\AClient" "AClient.db" /log:"C:\Program Files (x86)\SP\AClient\Acleint.txt" /tee

    if %ERRORLEVEL% EQU 16 GOTO ER16
    if %ERRORLEVEL% EQU 1 GOTO ER1
    if %ERRORLEVEL% EQU 0 GOTO ER0

:ER0
2>nul POPD >nul 
PUSHD "\\sampleserver\123\123\"
Start /b "" cscript "NoCopy.vbs"
TIMEOUT /T 3
POPD
exit

:ER1
2>nul POPD >nul 
PUSHD "\\sampleserver\123\123\"
Start "" cmd /c cscript "Success.vbs"
TIMEOUT /T 3
POPD
exit

:ER16
2>nul POPD >nul 
PUSHD "\\sampleserver\123\123\"
Start /b "" cscript "FatalError.vbs"
TIMEOUT /T 3
POPD
exit

1 个答案:

答案 0 :(得分:0)

您可以在vbs中使用mshta而不是msgbox

Function mshta(ByVal MessageText, ByVal Title, ByVal PauseTimeSeconds)

    Set WScriptShell = CreateObject("WScript.Shell")
    ConfigString = "mshta.exe vbscript:close(CreateObject(""WScript.Shell"")." & "Popup(""" & MessageText & """," & PauseTimeSeconds & ",""" & Title & """))"
    WScriptShell.Run ConfigString

End Function

“ PauseTimeSeconds”将关闭该消息,或者您可以将其设置为0,使其保持打开状态,直到用户单击“确定”为止。