[VBScript / Batch] Windows Dialog MsgBox Tool for Batch Files

Discussion in 'Scripting' started by anemeros, Jan 31, 2011.

  1. anemeros

    anemeros MDL Developer

    Aug 12, 2009
    #1 anemeros, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    This is a tiny little script intended to make it possible (and easy) to use windows dialog functionality from batch files.

    msgbox.vbs [title] [message] [buttons]

    [title] the title of the dialog.
    [message] the content of the message box.
    [buttons] the sum of values used to determine the icon, buttons, and modality of the message box.​
    "{cr}" can be used in the message in place of a carriage return (newline).
    "{qt}" can be used in the message in place of a double quotation mark (").

    Using a value or a sum of values from the following list, you can specify the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. The first group (0–5) describes the buttons to be displayed in the message box, the second group (16, 32, 48, 64) describes the icon style, the third group (0, 256, 512, 768) indicates which button is the default; and the fourth group (0, 4096) determines the modality of the message box. When adding numbers to create a final value for the buttons parameter, use only one number from each group.

    • 0 = vbOKOnly - OK button only
    • 1 = vbOKCancel - OK and Cancel buttons
    • 2 = vbAbortRetryIgnore - Abort, Retry, and Ignore buttons
    • 3 = vbYesNoCancel - Yes, No, and Cancel buttons
    • 4 = vbYesNo - Yes and No buttons
    • 5 = vbRetryCancel - Retry and Cancel buttons
    • 16 = vbCritical - Critical Message icon
    • 32 = vbQuestion - Warning Query icon
    • 48 = vbExclamation - Warning Message icon
    • 64 = vbInformation - Information Message icon
    • 0 = vbDefaultButton1 - First button is default
    • 256 = vbDefaultButton2 - Second button is default
    • 512 = vbDefaultButton3 - Third button is default
    • 768 = vbDefaultButton4 - Fourth button is default
    • 0 = vbApplicationModal - Application modal (the current application will not work until the user responds to the message box)
    • 4096 = vbSystemModal - System modal (all applications wont work until the user responds to the message box)
    The ERRORLEVEL environment variable will return the number of the button that was clicked in the dialog.
    • 1 = vbOK - OK was clicked
    • 2 = vbCancel - Cancel was clicked
    • 3 = vbAbort - Abort was clicked
    • 4 = vbRetry - Retry was clicked
    • 5 = vbIgnore - Ignore was clicked
    • 6 = vbYes - Yes was clicked
    • 7 = vbNo - No was clicked

    msgbox.vbs "Failure" "The target file could not be reassembled!{cr}{cr}Press {qt}Retry{qt} to try again, or {qt}Cancel{qt} to skip to the next target." 37
    IF %ERRORLEVEL% EQU 4 (echo.Retry was pressed.) ELSE (IF %ERRORLEVEL% EQU 2 (echo.Cancel was pressed.))

    Here's the script, nice and short:
    ' MsgBox v1.0 by anemeros
    set args=WScript.Arguments
    wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0))

    Attached Files:

  2. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    lol...anemeros is still around in D420, what is funny is I'm pretty sure he and sec9tos had way to delete WPA inside windows but they would never tell me :eek:

    But there is another that might know and his name begins with a P :roflmao:...lol
  4. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    #5 timesurfer, Apr 26, 2013
    Last edited: Apr 26, 2013
    @S77 and Humphrey

    Please post your code of my ideas in D420 in batch repo?

    1. Color customization
    2. Eliminate manual rearm
    3. Theme restore/backup
    4. IR6 reinstall msg

    and Humphreys

    5. direct link download for ISO/URL/Torrent

    You guys are amazing and anyone who develops at MDL is lucky, no blessed, to gain your assistance

    I only wish MD was here to see all my accomplishments with your and others gracious help

    He was like a batch file father to me and made my life fun and exciting when I had nothing to be excited about and at a time when I was first taking computer classes and what a f'n blessing to have the rearm concept fall into my lap and be my endevour and to receive such well timed help from the MDL crew all admins/mods/owner and members included

    It was also nice to able to have a custom solution/concept for myself but to later grow into the realization that in supporting the rearm concept, it was for the whole world not just myself and that gives me comfort and joy for life is not just for ourselves but everyone and MDL is a reflection of that giving and bless MDL

    You all really made my day if several 1000's posts = one day :eek:

    I miss MD :weep: