Messagebox is a tiny portable tool for displaying messages and questions from batch files or scripts.
The program can be used just to show a warning ("xyz will happen next"), or to ask a question and return the result as an ErrorLevel.
The syntax looks like this:
messagebox message title [type]
The most interesting element is the optional "type", which defines the icon displayed, the buttons used, and which button is the default.
To set it up, you would find the settings you need and add up those values.
set MB_ABORTRETRYIGNORE=2
set MB_CANCELTRYCONTINUE=6
set MB_OK=0
set MB_OKCANCEL=1
set MB_RETRYCANCEL=5
set MB_YESNO=4
set MB_YESNOCANCEL=3
rem Icon.
set MB_ICONEXCLAMATION=48
set MB_ICONWARNING=48
set MB_ICONINFORMATION=64
set MB_ICONASTERISK=64
set MB_ICONQUESTION=32
set MB_ICONSTOP=16
set MB_ICONERROR=16
set MB_ICONHAND=16
rem Default button.
set MB_DEFBUTTON1=0
set MB_DEFBUTTON2=256
set MB_DEFBUTTON3=512
set MB_DEFBUTTON4=768
rem Other options.
set MB_SETFOREGROUND=65536
rem Result ERRORLEVELs.
set IDOK=1
set IDCANCEL=2
set IDRETRY=4
set IDABORT=3
set IDIGNORE=5
set IDYES=6
set IDNO=7
set IDTRYAGAIN=10
set IDCONTINUE=11
For example, using Retry and Cancel buttons gives us a value of 5; setting Retry as the default is a value of 4; an exclamation mark icon is 48. That's a total of 57, and we'd use it in a line like this:
messagebox "We've failed to do something important", "Horrible Error", 57
Checking ErrorLevel in the batch file would then give us 4 if the user selected Retry, 2 for Cancel.
Verdict:
There are plenty of tools around to display messages from scripts, but Messagebox has several advantages: it has no dependencies, runs on anything from Windows NT 4.0 up, is free for all purposes, and gives you the power to use whatever combination of (standard) buttons and icons you need.
Your Comments & Opinion
The ultimate command line toolkit?
A Chrome extension for chatting, video calling and more
Send and receive free phone calls and text messages from your iPhone
A powerful, portable Notepad replacement
A powerful, portable Notepad replacement
A powerful, portable Notepad replacement
A powerful, portable Notepad replacement
Easily create responsive websites, no design skills required.