Introduction: How to Add Message Boxes in Batch Programming

About: Hello, my name is xp4xbox, a really old name that really has nothing to do with xbox consoles. Anyway I enjoy making programs and have several instructables on some of them. So far, I know VBScript, Batch, Pow…

Have you ever wanted to add a graphical interface for your batch files like you can in VBScript? I sure have. But now you can with this awesome program called MessageBox.

Step 1: Installation

You can download the program here-------->LINK

After you have downloaded and extracted the file, move the file called MSGBOX.EXE to your system32 folder, usually it is in C:\windows\system32.

Step 2: Test

Now, open up cmd and type msgbox and you should see it's syntax. You can also run the example.bat to test it out as well. So in case you did not understand how to use it, I have an example below:

Msgbox "Hello\n\nDo you want to continue ?" "This is a Message Box" YESNO

-

So first the "Hello\n\nDo you want to continue ?". This is the body message. The "\n\n" is a carriage return.

-

Second the "This is a Message Box". This is the Title in the Message Box.

-

Third the "YESNO". This are the buttons that would show on the Message Box. The following combinations are:

YESNO, YESNOCANCEL, OKCANCEL and if left blank then it would just display OK.

-

So now that you know how the MsgBox function works, you can now add functions when a button is clicked.

Example in a batch script:

@echo off

Msgbox "Hello\n\nDo you want to continue ?" "This is a Message Box" YESNOCANCEL

if %errorlevel%==6 GOTO yes

if %errorlevel%==7 GOTO no

if %errorlevel%==2 GOTO cancel

::OK would be: if %errorlevel%==1 goto OK

:yes

echo You clicked Yes

pause >NUL

exit

:no

echo You clicked No

pause >NUL
exit

:cancel

echo You Clicked on Cancel

pause >NUL
exit

Step 3: Enjoy!

Now you can enjoy that Message Box Function!

If you have any questions or concerns please write a comment or PM me.