Purpose:Display a Windows message box

 

Format:MSGBOX [/1["text"] /2["text"] /3["text"] /4["text"] /Dn /H /I /L /M /N /O /Px,y /Q /R /S /Tn /V /W] buttontype ["title"] prompt

 

buttontypeOne of OK, OKCANCEL, YESNO, YESNOCANCEL, RETRYCANCEL, ABORTRETRYIGNORE, CANCELTRYCONTINUE, or CONTINUEABORT
titleText for the title bar of the message box.
promptText that will appear inside the message box.

 

/1 (st button)/N (no sound)
/2 (nd button)/O (topmost window)        
/3 (rd button) /P (screen coordinates)
/4 (th button)/Q(uestion icon)
/D(isable temporarily)/R(ight justify buttons)        
/H(elp button)/S(top icon)
/I(nformation icon)/T(imeout)
/L(imit width)/V(ista style)        
/M (system modal)/W(arning icon)

 

See also: INKEY, INPUT, QUERYBOX, and TASKDIALOG.

 

Usage:

 

MSGBOX can display one of eight kinds of message boxes and wait for the user's response. You can use title and prompt to display any text you wish. TCC will automatically size and center the message box on the screen. The message box has up to three response buttons (plus an optional Help button), depending on its type, as shown below.

 

buttontype

button 1

button 2

button 3

OK

OK



OKCANCEL

OK

Cancel


YESNO

Yes

No


YESNOCANCEL

Yes

No

Cancel

RETRYCANCEL

Retry

Cancel


ABORTRETRYIGNORE

Abort

Retry

Ignore

CANCELTRYCONTINUE

Cancel

Try Again

Continue

CONTINUEABORT

Continue

Abort


 

If the standard message box types don't meet your needs, you can create a custom message box with up to four buttons (plus an optional Help button), specifying the text that appears on each button.

 

The button the user chooses is indicated using the internal variable %_?. Be sure to save the return value in another variable or test it immediately; because the value of %_? changes with every internal command. The following list shows the value returned for each selection:

 

response

%_?

Yes or OK

10

No

11

Cancel

12

Retry

13

Try Again

14

Continue

15

Ignore

16

Abort

17

Help

18

timeout

20

custom button 1

21

custom button 2

22

custom button 3

23

custom button 4

24

 

If you define custom buttons, the button type argument will be ignored.

 

If there is an error in the MSGBOX command itself, %_? will be set as described in its documentation (see _?).

 

For example, to display a Yes or No message box and take action depending on the result, you could use commands like this:

 

msgbox yesno "Copy" Copy all files to A:?

if %_? == 10 copy * a:

 

Since MSGBOX doesn't write to standard output, it disables redirection and piping to allow you to enter the redirection characters (<, >, and |) in your prompt text.

 

MSGBOX creates a popup dialog box. If you prefer to retrieve input from the command line, see the INKEY and INPUT commands.

 

Options:

 

/1If there is a text string following the option, set the custom text for the first button. Otherwise, set the first button as the default.

 

/2 If there is a text string following the option, set the custom text for the second button. Otherwise, set the second button as the default.

 

/3If there is a text string following the option, set the custom text for the third button. Otherwise, set the third button as the default.

 

/4If there is a text string following the option, set the custom text for the fourth button. Otherwise, set the fourth button as the default.

 

/DnDisable the message box buttons for n seconds at startup.

 

/HDisplay a help button.

 

/IDisplay an icon consisting of a lower case "i" in a circle in the message box.

 

/LLimit the maximum message box width to no more than 1/3 the screen width (unless the button text requires more).

 

/MThe message box window will be displayed on top of all other windows.

 

/NDon't play the default sound.

 

/O The message box is created as a topmost window.

 

/Px,yThe initial x,y screen coordinates. If you don't use this option, MSGBOX will center its window in the TCC tab window.

 

/QDisplay a question mark icon in the message box.

 

/RThe buttons will be right-justified.

 

/SDisplay a stop sign icon in the message box.

 

/TnMSGBOX will wait a maximum of n seconds for a response (and then close). If the time limit expires, %_? will be set to 20. The time remaining before the window closes will be displayed in the default button.

 

/VDisplay the message box in the Windows 7 / 8 / 10 style (the message background will be the current window color, the buttons will be right-justified and slightly bigger, and the position of icon and message will be adjusted.)  This is the default in Windows 7 and later.

 

/WDisplay an exclamation point icon in the message box.