[RELEASE] Advanced MSGBOX Command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nitt
Posts: 218
Joined: 22 Apr 2011 02:43

[RELEASE] Advanced MSGBOX Command

#1 Post by nitt » 29 May 2011 11:23

This MSGBOX command can do everything the C# MessageBox.Show() function can do.

Here is what you get when you type in "msgbox /?":

Displays a message box and returns the value.

MSGBOX [body] [title] [type]

body Specifies the text of the body of the message box
title Specifies the text of the title of the message box
type Specifies the type of message box

Type attributes are specified by TWO hex digits -- these both correspond to the icon and buttons of the message box.

0 = Abort/Retry/Ignore C = Exclamation
1 = OK D = Hand
2 = OK/Cancel E = Information
3 = Retry/Cancel F = None
4 = Yes/No G = Question
5 = Yes/No/Cancel H = Stop
A = Asterik I = Warning
B = Error

Example: "MSGBOX body title 2B" produces an error dialog with the buttons OK and Cancel.


As you can see, it may seem a little complex on how to use. But it's not.

Here is an example of a code:

Code: Select all

@echo off
msgbox "Are you epic?", "Question", 4g > tmp
set /p result=< tmp
del tmp
if %result% EQU Yes echo You're not epic, you lier!
if %result% EQU No echo Yes, exactly. You are a fail.
pause


When you set a message box, the result of whatever button you press is the output. Such as if I press "Abort" it will return "Abort".

Also, "4g" and "g4" are the same thing. "4" sets the message box to have the buttons "Yes" and "No". "g" sets it to a question box. The letters are not case sensitive.

http://dl.dropbox.com/u/10434417/releases/commands/MSGBOX.exe

I'd like some positive feedback or constructive criticism. I am tired of trolls.


Note: This is actually more powerful than the VBScript MSGBOX.

Post Reply