Messagebox is a tiny transportable device for displaying messages and questions from batch information or scripts.
This system can be utilized simply to indicate a warning (“xyz will occur subsequent”), or to ask a query and return the consequence as an ErrorLevel.
The syntax appears like this:
messagebox message title [type]
Essentially the most fascinating component is the elective “kind”, which defines the icon displayed, the buttons used, and which button is the default.
To set it up, you’ll discover the settings you want and add up these 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 Different choices.
set MB_SETFOREGROUND=65536
rem Consequence 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 instance, utilizing Retry and Cancel buttons provides us a price of 5; setting Retry because the default is a price of 4; an exclamation mark icon is 48. That is a complete of 57, and we might use it in a line like this:
messagebox “We have didn’t do one thing essential”, “Horrible Error”, 57
Checking ErrorLevel within the batch file would then give us 4 if the person chosen Retry, 2 for Cancel.
Verdict:
There are many instruments round to show messages from scripts, however Messagebox has a number of benefits: it has no dependencies, runs on something from Home windows NT 4.0 up, is free for all functions, and provides you the facility to make use of no matter mixture of (customary) buttons and icons you want.
(0)
(0)
Danyil Bohdan
Developer & Programming