Passing the output of vbYesNoCancel into a batch

前端 未结 1 400
半阙折子戏
半阙折子戏 2021-01-26 16:18

Good day, I am cuurently writing a batch file for a simple program and I am using VBscript to recieve input from users. At this point in the program I have the question: \"Would

相关标签:
1条回答
  • 2021-01-26 17:00
    @echo off
    
        call :MsgBox "Should i do something?"  "VBYesNoCancel+VBQuestion" "Just asking"
        if errorlevel 7 (
            echo NO - do nothing
        ) else if errorlevel 6 (
            echo YES - do something
        ) else if errorlevel 2 (
            echo CANCEL - do .....
        )
    
        exit /b
    
    :MsgBox prompt type title
        setlocal enableextensions
        set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
        >"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
        set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
        endlocal & exit /b %exitCode%
    

    For a simple MsgBox, it is better to use WScript.Quit to return as an errorlevel the result of the MsgBox function

    0 讨论(0)
提交回复
热议问题