External MessageBox

I wrote External MessageBox about year ago for use in a batch scripts to control execution flow and communicate with a user.
The utility is very simple, as the name suggests it shows the dialog box with specified caption, message, icon and one or several buttons. If you look at the source code you'll see that it just a call of the system MessageBox function (more about it here).
One of the cool feature is that you can pin the MessageBox to another running application, and block it until the user click one of the buttons.
Here is an example:
  1. Run windows calculator (calc.exe),
  2. Open cmd shell and change directory to where you unzip the emsgbox.exe,
  3. run following command:

emsgbox.exe /n calc.exe /c Calculator Info /m 2+2=5 /t 48

The calulcator will be blocked until you click OK button.
The button number which user has clicked is placed in %errorlevel% environment variable (or $lasterrorcode - powershell), however this method works only if you write a batch script or in the cmd shell when you use emsgbox.exe as follow:

start /wait emsgbox.exe /n calc.exe /c Calculator Info /m 2+2=5 /t 48
echo %errorlevel%


(as I said if you use it in batch script you don't have to use "start /wait" statement)
Link to the project/download page:

0 comments:

Post a Comment