Categories:
command prompt program, batch script aid
Usage:
MSGBOX [/Time] [/Ccaption_text] [/S#style] message_text
Arguments:
message_text .. one or more words to display in the message window. The following escape sequences are supported within the message text. \\ -- a single backslash \n -- line feed \r -- carriage return \t -- tab Usually lines are terminated by a \r\n sequence. Lines are double-spaced by using a \r\n\r\n sequence.
Optional arguments:
/Ccaption_text .. sets the text that appears in the message window's caption. Notice the caption text immediately follows the 'C'. If spaces appear in the caption text, then the entire argument must be enclosed in double-quotes. /S#style .. the message window's style .. a numeric sum of up to four of the following numeric style values 1. type of button(s) to use 0 - OK 1 - OK(1) Cancel(2) 2 - Abort(3) Retry(4) Ignore(5) 3 - Yes(6) No(7) Cancel(2) 4 - Yes(6) No(7) 5 - Retry(4) Cancel(2) 2. optional, type of icon to display within the message 16 - stop image 32 - question mark 48 - exclamation mark 64 - information bubble 3. optional, default button selector 256 - the second button receives the initial focus 512 - the third button receives the initial focus 1024 - the fourth button receives the initial focus 4. optional, final style 262144 - indicates message window will float above all other windows Thus, a style value of 292 (4 + 32 + 256) is interpreted as: show 'Yes' and 'No' buttons 4 the 'question mark' icon is displayed + 32 the 'No' button initially has the focus + 256 ===== total: 292 /Time .. shows the current time in front of the message
Redirected input file:
N/A
Redirected output file:
N/A
Returns:
0 .. processing completed successfully 1 .. the OK button was pressed 2 .. the Cancel button was pressed 3 .. the Abort button was pressed 4 .. the Retry button was pressed 5 .. the Ignore button was pressed 6 .. the Yes button was pressed 7 .. the No button was pressed
Description:
The MSGBOX program is very useful for showing message windows in batch scripts. The buttons that are pressed in the message window can alter subsequent script processing. An example shows how the MSGBOX program can be used in a batch script to conditionally erase a file.
Remarks:
The QUERY program provides a simpler way of showing a 'Yes' or 'No' message window within a batch script.
Examples:
MSGBOX "/CMagic words" abra\r\nca\r\ndabra In a batch script: MsgBox "/CCareful !" /S292 Do you want to erase file %1 ? if errorlevel 7 goto :skip erase %1 goto :quit :skip echo File %1 was NOT erased. :quit
See also:
query,