Last Updated 5/1/1999 -
Batch files hold the computing world together. They are often the
tool of choice when automating routine tasks. Most of the time
these batch files work quietly in the background, often out of
sight of our end users; but sometimes we create files that
may need to interact with their users. Recently while creating
such a file it occurred to me that instead of a simple text based
interface I could use the Windows API to facilitate user interaction.
MBox was the result, it displays a Windows(tm) message box in
accordance with command-line input and returns an error code based
on which button user pushes. Hopefully others will find it as useful
as I have when creating batch files in a Windows-based environment.
- mbox.exe Button_Type Message_Text [Title_Bar_Text] [Icon]
- The Button_Type and Message_Text fields are required,
the Title_Bar_Text and Icon are optional but if both are
specified the Title_Bar_Text must be first. As you might expect
any text field with spaces must be surrounded with double quotes.
- Button Types:
Button_Type Resulting Buttons
OKCAN OK Cancel
YN Yes No
YNC Yes No Cancel
RC Retry Cancel
ARI Abort Retry Ignore
Icon Description Sample
- Return Codes:
- The following error codes are used to indicate which button the
user selected. A return code of zero indicates that the program was
unable to create the message box.
Return Code Button Pushed
- mbox.exe OKCAN "Continue with install?" "MyApp Installer" QUEST
- mbox.exe RC "Files not updated." "Update Script" STOP
- mbox.exe YESNO "Reboot System?" MyApp
- mbox.exe OK "Go Vikings!"
- Your batch file might look something like this:
- @echo off
- mbox.exe OKCAN "Continue with install?" QUEST
- if %errorlevel% == 1 goto continue
- if %errorlevel% == 2 goto end
- echo Unexpected return value, abort.
- goto end
- echo Install commands go here.
- Downloading: MBox is Freeware, see legal Mumbo-Jumbo below for details.
- Source code is also available, just remember where it came from. :-)
- MBox 1.0 (mbox.exe - 33,280 bytes)
- MBox Source Code (in Visual C++ version 5.0)
- Programming Notes:
- Anyone familiar with Windows programming will quickly realize
that the Windows MessageBox API code is doing most of the work here.
But then again its a computer, its suppose to be doing the hard
work for us...
- Legal Mumbo-Jumbo:
- Feel free to download, use, and distribute this software as you wish
so long as the readme.txt document is included, both are unchanged, and no fee is
charged. This software has been tested, but I am not responsible for
anything that occurs to your computer.
- Use at your own risk, yada, yada, yada.