Stephen Knight
03/11/2013 04:27 PM
GUI Yes/No or Message box in batch file


VBScript, Batch/Command file


This script demonstrates a way to show a GUI messagebox from a batch file to ask Yes/No question, and return the answer to a batch file, also a plain text box with just an "OK"
Show details for CodeCode
Hide details for CodeCode
@echo off
Call :YesNoBox "Are you sure you want to do that?"
if "%YesNo%"=="7" (
Call :MessageBox "You answered NO" "Heading"
exit /b

exit /b
REM returns 6 = Yes, 7 = No. Type=4 = Yes/No
set YesNo=
set MsgType=4
set heading=%~2
set message=%~1
echo wscript.echo msgbox(WScript.Arguments(0),%MsgType%,WScript.Arguments(1)) >"%temp%\input.vbs"
for /f "tokens=* delims=" %%a in ('cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"') do set YesNo=%%a
exit /b

set heading=%~2
set message=%~1
echo msgbox WScript.Arguments(0),0,WScript.Arguments(1) >"%temp%\input.vbs"
cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"
exit /b

Show details for ExplanationExplanation
Hide details for ExplanationExplanation
Show details for ExamplesExamples
Hide details for ExamplesExamples

Show details for AttachmentsAttachments
Hide details for AttachmentsAttachments