The demise of NET SEND
and the absence of MSG.EXE
in Windows * Home Editions made me write some dialog box utilities for batch files.
Except for ColorSelectBox, FontSelectBox, ProgressBarGUI and SystemTrayMessage, the command line arguments for these utilities are mostly optional, but they are "location sensitive", i.e. MessageBox' "title" argument must be the second command line argument if specified at all. So in order to specify a title, you also need to specify a message for MessageBox — which isn't an unreasonable requirement for a MessagBox.
All dialog box utilities presented on this page except ProgressBarGUI write the relevant selection, or entered text, to Standard Output, to allow capturing the result in a FOR /F loop.
All these dialog box utilities except ColorSelectBox, FontSelectBox, InputBoxWF and ProgressBarGUI return an "Errorlevel" 0 if all went well and the "OK" button was clicked (or the "Enter" key pressed), 1 in case of command line errors or unexpected errors, 2 if the "Cancel" button was clicked (or the "Esc" key pressed or the "X" at the upper right corner of the window clicked, or "Alt+F4" pressed).
DropDownBox, ColorSelectBox and FontSelectBox have command line switches to override default errorlevels, so carefully read these utilities' help texts before trying to use their errorlevels.
Note that "capturing" Errorlevels isn't really straightforward in FOR /F loops.
A sample of batch code with complete error handling:
FOR /F "tokens=*" %%A IN ('PrinterSelectBox.exe ^|^| ECHO Error^& IF ERRORLEVEL 2 ECHO Cancel') DO SET Printer=%%A IF "%Printer%"=="Cancel" ( ECHO ErrorLevel 2: You clicked "Cancel" ) ELSE ( IF "%Printer%"=="Error" ( ECHO ErrorLevel 1: An error occurred ) ELSE ( ECHO ErrorLevel 0: You selected "%Printer%" ) )
Of course you are free to reduce error handling, and just use a default value if no valid selection was made:
SET Printer=Default Printer FOR /F "tokens=*" %%A IN ('PrinterSelectBox.exe') DO SET Printer=%%A SET Printer
The following dialog boxes are available:
MessageBox |
|||||||||||||||||||||||||||||||||||||||||
MessageBox.exe does what its name suggests: it shows a simple message in a popup window. Like its VBScript counterpart it returns the "answer", i.e. a code for the button that was clicked. But unlike its VBScript counterpart, the answer isn't returned as an integer, but as a string, i.e. the (English, lower case) caption of the button that was clicked. You can specify the message text, the window title, the buttons and icon, the default button, even right alignment or rigt-to-left reading, and an optional timeout. Unlike most of my command line utilities, MessageBox displays its help text in two MessageBoxes as well as in Standard Error: MessageBox.exe, Version 1.34 Batch tool to show a message in a MessageBox and return the caption of the button that is clicked Usage: MessageBox "message" [ "title" ] [ switches ] or: MessageBox "message" "title" buttons icon default [option] timeout Where: buttons "AbortRetryIgnore", "OK", "OKCancel", "RetryCancel", "YesNo" or "YesNoCancel" icon "Asterisk", "Error", "Exclamation", "Hand", "Information", "None", "Question", "Stop" or "Warning" default "Button1", "Button2" or "Button3" or the default button's (English) caption option "HideConsole", "NoEscape", "RightAlign", "RtlReading", "None" or "" timeout timeout interval in seconds Switches: /B:buttons A = AbortRetryIgnore, O = OK, C = OKCancel, R = RetryCancel, Y = YesNo, N = YesNoCancel /I:icon A = Asterisk, E = Error, X = Exclamation, H = Hand, I = Information, N = None, Q = Question, S = Stop W = Warning /D:default 1 = Button1, 2 = Button2, 3 = Button3 or use the default button's (English) caption /O:option H = HideConsole, N = NoEscape, R = RightAlign, L = RtlReading /R Return code tells which button was clicked (see Notes) /T:timeout timeout interval in seconds Notes: Use switches if you want to skip arguments. Always specify buttons BEFORE specifying default. Using the "HideConsole" option will hide the console window permanently, thereby disabling all console based user interaction (e.g. "ECHO" and "PAUSE"). It is intended to be used in scripts that run "hidden" themselves, e.g. VBScript with the WScript.exe interpreter. Do not use this option in a batch file unless hiding the console window permanently is intended. Linefeeds (\n or \012 and/or \r or \015), tabs (\t or \007), singlequotes (' or \047) and doublequotes (\" or \042) are allowed in the message string. Unicode characters (e.g. "\u5173" for "?") are allowed in the message string and in the title. By default, however, these linefeeds, tabs, quotes and Unicode characters will be escaped to allow correct display of paths. Use option "NoEscape" to disable all character escaping except doublequotes. The (English) caption of the button that was clicked is returned as text to Standard Output (in lower case), or "timeout" if the timeout interval expired. When using the timeout feature, A window with the current MessageBox's TITLE will be closed, not necessarily THE current MessageBox. To prevent closing the wrong MessageBox, use unique titles. The timeout feature should not be combined with buttons Abort Retry Fail; if it is, the MessageBox will remain open even after the timeout expires, until a button is clicked, and then return the "timeout" result. Unless the /R switch is used, the return code of the program is 0 if a button was clicked, 1 in case of (command line) errors, 2 if cancelled (this does require a Cancel button), 3 if the timeout expired. When the /R switch is used, the return code of the program is 1 if button 1 was clicked, 2 if button 2 was clicked, 3 if button 3 was clicked, 4 if the timeout expired, -1 in case of (command line) errors, or 0 if the MessageBox is cancelled without a Cancel button being available. Credits: Code to hide console by Anthony on: http://stackoverflow.com/a/15079092 MessageBox timeout based on code by DmitryG on: http://stackoverflow.com/a/14522952 Written by Rob van der Woude https://www.robvanderwoude.comMessageBox.exe is built using the .NET FrameWork's MessageBox Class. Of all dialog boxes on this page, MessageBox.exe is the only one that can be used by scheduled tasks (with credentials different from the logged in user's) to display a message on the default desktop. |
|||||||||||||||||||||||||||||||||||||||||
RichTextMessageBox |
|||||||||||||||||||||||||||||||||||||||||
RichTextMessageBox.exe is the "posh" version of MessageBox.exe. Like MessageBox.exe it returns the "answer" as the caption of the button that was clicked. You can specify the message text, the window title, one to three buttons with custom caption, the default button, font family, size and attributes, text color, window size and location, modality, whether it shows up on the taskbar when running, and an optional timeout. Unlike most of my command line utilities, RichTextMessageBox displays its help text in a RichTextMessageBox as well as in Standard Error: RichTextMessageBox, Version 1.03 Show a fully customizable message dialog and return which button is clicked Usage: RichTextMessageBox.exe message [ title ] [ options ] message is the text to be displayed in the dialog title is the dialog's window title (default: program name and version) Options: /AlwaysOnTop Modal window, always on top /B1:"caption" Caption for button 1 (default: OK) /B2:"caption" Caption for button 2 (default: empty) /B3:"caption" Caption for button 3 (default: empty) /BH:height Button height (default: 25) /Bold Bold text for message /BW:width Button width (default: 100) /C:color Text color for dialog (default: Black) /DB:default Default button (default: 1; values 2 or 3 are valid only if there are that many buttons) /Font:name Font family name (default: Sans-Serif) /FS:fontsize Font size (default: 12) /Italic Italic text for message /Literal Treat message as literal, do not interpret special characters \n, \012, \t, \007 or unicode \u**** (default: interpret special chars and unicode) /Strike Strikeout text /T:seconds Timeout in seconds (default: no timeout) /Taskbar Show in taskbar /Underline Underline text /WH:height Window height (default: 480) /WW:width Window width (default: 640) /X:x X-coordinate of upper left window corner /Y:y Y-coordinate of upper left window corner (default: center window on screen) Notes: The caption of the button that is clicked will be sent to the console, the number of the button is returned as "errorlevel". In case of errors, the "errorlevel" will be -1, if a timeout elapsed and no default button was specified, the "errorlevel" will be 4, and the text "Timeout" is sent to the console. If an invalid text color is specified, it will be ignored. Written by Rob van der Woude https://www.robvanderwoude.com/Unlike MessageBox.exe, RichTextMessageBox can not be used by scheduled tasks (with credentials different from the logged in user's) to display a message on the default desktop. |
RichTextMessageBox.exe "RichTextMessageBox.exe Message /Font:Papyrus /C:blue /FS:16 /B1:Yes /B2:No /B3:Cancel" /font:"Papyrus" /c:blue /fs:16 /B1:Yes /B2:No /B3:Cancel |
||||||||||||||||||||||||||||||||||||||||
InputBox |
|||||||||||||||||||||||||||||||||||||||||
InputBox.exe was first built using the .NET FrameWork's Interaction.InputBox Method, but I found it too ugly. A dynamically created Windows Form allowed me more freedom in design. A large part of the C# code for InputBox.exe comes from Gorkem Gencay on StackOverflow.com. You can specify the "prompt" text, the window title, the default value (already entered in the input text field, option not available for masked password input), an optional timeout in seconds, and the dialog box width and height, disable filtering of "risky" characters & < > | and ", add regular expression based filtering and/or an input mask (input text template), whether or not to hide (mask) the input text (for password input) and whether or not to insert a "Show password" checkbox. When the "OK" button is clicked, the entered text is written to Standard Output. If the dialog times out and a default text was specified, that default text is written to Standard Output. Warning: If /N is used, either use doublequotes to "capture" the result (in a FOR /F loop), or redirect the result to a file.InputBox, Version 1.38 Prompt for input (GUI) Usage: INPUTBOX [ "prompt" [ "title" [ "default" ] ] ] [ options ] Where: "prompt" is the text above the input field (use \n for new line) "title" is the caption in the title bar "default" is the default answer shown in the input field Options: /A accepts ASCII characters only (requires /M) /B use standard Black and white in console, no highlighting /F:regex use regex to filter input on-the-Fly (see Notes) /H:height sets the Height of the input box (default: 110; minimum: 110; maximum: screen height) /I regular expressions are case Insensitive (default: regular expressions are case sensitive) /L[:string] use Localized or custom captions (see Notes) /M:mask accept input only if it matches mask /N Not filtered, only doublequotes are removed from input (default: remove & < > | ") /O dialog window remains always On top /P hides (masks) the input text (for Passwords) /R:regex accept input only if it matches Regular expression regex /S[:text] inserts a checkbox "Show password" (or specified text) /T[:sec] sets the optional Timeout in seconds (default: 60) /U return Unmasked input, without literals (requires /M) (default: include literals in result) /W:width sets the Width of the input box (default: 200; minimum: 200; maximum: screen width) Example: prompt for password InputBox.exe "Enter your password:" "Login" /S Example: fixed length hexadecimal input (enter as a single command line) InputBox.exe "Enter a MAC address:" "MAC Address" "0022446688AACCEE" /M:">CC\:CC\:CC\:CC\:CC\:CC\:CC\:CC" /R:"[\dA-F]{16}" /F:"[\dA-F]{0,16}" /U /I Notes: For hidden input (/P and/or /S), ), "default" will be ignored. With /F, regex must test the unmasked input (without literals), e.g. /M:"CC:CC:CC:CC:CC:CC:CC:CC" /F:"[\dA-F]{0,16}" /I for MAC address. With /R, regex is used to test input after OK is clicked; with /F, regex is used to test input each time the input changes, so regex must be able to cope with partial input; e.g. /F:"[\dA-F]{0,16}" is OK, but /F:"[\dA-F]{16}" will fail. Be careful with /N, use doublequotes for the "captured" result, or redirect the result to a (temporary) file. Show password (/S) implies hiding the input text (/P). Use /M (without mask) to show detailed help on the mask language. Use /L for Localized "OK" and "Cancel" button captions. Custom captions require a string like /L:"OK=caption;Cancel=caption" (button=caption pairs separated by semicolons, each button optional) Text from input is written to Standard Output only if "OK" is clicked. Return code is 0 for "OK", 1 for (command line) errors, 2 for "Cancel", 3 on timeout, 4 if no regex or mask match. Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/97097#17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Written by Rob van der Woude http://www.robvanderwoude.comIf you intend to use an input mask, type InputBox.exe /M to show detailed help for the mask "language".
|
INPUTBOX.EXE "Prompt" "Title" "Default answer" INPUTBOX.EXE "Enter your password:" "Login" /S INPUTBOX.EXE "Enter a MAC address:" "MAC Address" "0022446688AACCEE" /M:">CC\:CC\:CC\:CC\:CC\:CC\:CC\:CC" /R:"[\dA-F]{16}" /F:"[\dA-F]{0,16}" /U /I INPUTBOX.EXE "Typ uw wachtwoord" "Inloggen" /S:"Toon wachtwoord" /L:"Cancel=Annuleren" |
||||||||||||||||||||||||||||||||||||||||
InputBoxWF |
|||||||||||||||||||||||||||||||||||||||||
InputBoxWF.exe is a Windows Form (GUI) version of InputBox.exe, which allows you to use it in non-console based scripts, e.g. VBScript, without a console box being displayed. It's current development state is best described as "beta". Being a Windows Form based program, InputBoxWF cannot write to a console, so you will have to send the result either to a file or to the clipboard; see the program's help dialogs for details. |
|||||||||||||||||||||||||||||||||||||||||
OpenFileBox |
|||||||||||||||||||||||||||||||||||||||||
Use OpenFileBox.exe to select an existing file. You can specify the required file type, the start folder, and the window title. The full path to the existing file is written to Standard Output. OpenFileBox.exe, Version 1.05 Batch tool to present an Open File Dialog and return the selected file path Usage: OPENFILEBOX [ "filetypes" [ "startfolder" [ "title" ] ] ] Where: filetypes file type(s) in format "description (*.ext)|*.ext" or just "*.ext" (default: "All files (*.*)|*.*") startfolder the initial folder the dialog will show on opening (default: current directory) title the caption in the dialog's title bar (default: "OpenFileBox, Version 1.05)" Notes: This batch tool does not actually open the selected file, it is only intended to interactively select a file, which can be used by the calling batch file. Multiple file types can be used for the filetypes filter; use "|" as a separator, e.g. "PDF files (*.pdf)|*.txt|Word documents (*.doc)|*.doc". If the filetypes filter is in "*.ext" format, "ext files (*.ext)|*.ext" will be used instead. Unless the filetypes filter specified is "All files (*.*)|*.*" or "*.*", the filetypes filter "|All files (*.*)|*.*" will be appended. The full path of the selected file is written to Standard Output if OK was clicked, or an empty string if Cancel was clicked. The return code will be 0 on success, 1 in case of (command line) errors, or 2 if Cancel was clicked. Written by Rob van der Woude http://www.robvanderwoude.comOpenFileBox.exe was built using the .NET FrameWork's OpenFileDialog Class, which implies that it can be used to manipulate files and folders. Always use permissions to manage user access to files and folders. |
|||||||||||||||||||||||||||||||||||||||||
SaveFileBox |
|||||||||||||||||||||||||||||||||||||||||
Use SaveFileBox.exe to select a target file to save to, existing or not. Besides the required file type, start folder, and window title, you can also specify the behaviour when the selected file already exists, or when the specified file does not exist. The full path to the selected file, existing or not, is written to Standard Output. SaveFileBox.exe, Version 1.03 Batch tool to present a Save File dialog and return the selected file path Usage: SAVEFILEBOX "filetypes" "startfolder" "title" options Where: filetypes file type(s) in format "description (*.ext)|*.ext" or just "*.ext" (default: "All files (*.*)|*.*") startfolder the initial folder the dialog will show on opening (default: current directory) title the caption in the dialog's title bar (default: "SaveFileBox, Version 1.03)" options /F Force specified extension /Q Quiet mode: do not check if the file exists /V Verbose mode: prompt for confirmation (default: prompt only if file exists) Notes: This batch tool does not actually save the file, it is only intended to interactively specify a file path, which can be used by the calling batch file. All command line arguments are optional, but each argument requires the ones preceeding it, e.g. "startfolder" requires "filetypes" but not necessarily "title" and options. Options /Q and /V are mutually exclusive. If the filetypes filter is in "*.ext" format, "ext files (*.ext)|*.ext" will be used instead. The full path of the selected file is written to Standard Output if OK was clicked, or an empty string if Cancel was clicked. The return code will be 0 on success, 1 in case of (command line) errors, 2 on Cancel, 3 if not in Quiet mode and file exists. Written by Rob van der Woude http://www.robvanderwoude.comSaveFileBox.exe was built using the .NET FrameWork's SaveFileDialog Class, which implies that it can be used to manipulate files and folders. Always use permissions to manage user access to files and folders. Note: make sure the path to the start folder does not end in a trailing backslash followed by a doublequote! |
|||||||||||||||||||||||||||||||||||||||||
OpenFolderBox |
|||||||||||||||||||||||||||||||||||||||||
Use OpenFolderBox.exe to select an existing folder. You can specify the start folder, the description above the tree view, and whether or not to hide the "Make New Folder" button. The full path to the selected folder is written to Standard Output. OpenFolderBox.exe, Version 1.03 Batch tool to present a Browse Folders Dialog and return the selected path Usage: OPENFOLDERBOX [ "startfolder" [ "description" ] ] [ /MD ] Where: "startfolder" is the initial folder the dialog will show on opening (default: current directory) "description" is the text above the dialog's tree view (default: "OpenFolderBox, Version 1.03") /MD display the "Make New Folder" button (default: hide the button) Notes: Though the "Make New Folder" button is hidden by default, this does not inhibit manipulating folders using right-click or Shift+F10. The full path of the selected folder is written to Standard Output if OK was clicked, or an empty string if Cancel was clicked. The return code will be 0 on success, 1 in case of (command line) errors, or 2 if Cancel was clicked. Written by Rob van der Woude http://www.robvanderwoude.comOpenFolderBox.exe was built using the .NET FrameWork's FolderBrowserDialog Class, which implies that it can be used to manipulate folders, even with the "Make New Folder" button hidden (try Shift+F10 or right-click). Always use permissions to manage user access to (files and) folders. Note: make sure the path to the start folder does not end in a trailing backslash followed by a doublequote! |
|||||||||||||||||||||||||||||||||||||||||
PrinterSelectBox |
|||||||||||||||||||||||||||||||||||||||||
Use PrinterSelectBox.exe to select an installed printer. You can specify the window title, the preselected printer (either by its full name or with a regular expression), and the dialog box width. The name of the selected printer is written to Standard Output. The original version used Windows' own Print dialog from the .NET FrameWork's PrintDialog Class, which has a lot of features we won't need in this utility. The current version has a more "Spartan" interface without the bells and whistles that didn't work in the old version. See the command lines below the sample dialogs to get an idea of PrinterSelectBox's possibilities. PrinterSelectBox, Version 2.07 Batch tool to present a Printer Select dialog and return the selected printer Usage: PRINTERSELECTBOX [ "title" [ "selected" ] ] [ options ] Where: "title" is the optional caption in the title bar "selected" is the optional selected printer, either its full name or a regular expression (default: the default printer name) Options: /H:height window Height(def: 220; min: 220; max: screen height) /L[:string] Use Localized or custom captions (see Notes) /M make dialog system Modal (i.e. always on top) /N list Network printers only (default: list all printers) /O list lOcal printers only (default: list all printers) /P[:text] Alternative "OK" button caption "Print" or "text" /W:width window Width (default: 400; min: 400; max: screen width) Notes: Use /L for Localized "OK" and "Cancel" button captions only. Custom captions require a "localization string" in the format /L:"key=value;key=value;..." e.g. for Dutch on English computers: /L:"Name=Naam;Where=Lokatie;Comment=Opmerking;Cancel=Annuleren" The name of the selected printer is written to Standard Out if the "OK" button is clicked, otherwise an empty string is returned. If "selected" is specified, the program will try an exact (literal) match first; if no match is found, "selected" will be interpreted as a regular expression, and the first match in the sorted printer list will be used. If no "title" is specified and /P is used, the alternative "OK" button caption ("Print" or "text") will be used for "title" too. Return code 0 for "OK", 1 for (command line) errors, 2 for "Cancel". Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/97097 /what-is-the-c-sharp-version-of-vb-nets-inputdialog#17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Written by Rob van der Woude http://www.robvanderwoude.com To present only a limited selection of all printers, use WMIC to make the selection and use DropDownBox to present the list (enter as a single command line): WMIC.EXE Printer WHERE "Network=TRUE" Get Caption | DROPDOWNBOX.EXE "Select a network printer" "Network Printer" /K /S
|
PRINTERSELECTBOX.EXE PRINTERSELECTBOX.EXE "Print File" /P PRINTERSELECTBOX.EXE "Selecteer een printer" /L:"Name=Naam;Where=Lokatie;Comment=Opmerking;Cancel=Annuleren"
|
||||||||||||||||||||||||||||||||||||||||
DateTimeBox |
|||||||||||||||||||||||||||||||||||||||||
Use DateTimeBox.exe to select a date and/or time within the specified range and return the selected value(s) in the specified output format. You can specify the window title, date or time only, input and output formats, and date range. The selected date/time is written to Standard Output in the specified output format. DateTimeBox, Version 1.12.1 Batch tool to present a Date/Time Picker dialog and return the selected date and/or time in the specified format Usage: DATETIMEBOX [ "title" ] [ "datetime" ] [ options ] Where: "title" is the optional caption in the title bar (default: DateTimeBox, Version 1.12.1) "datetime" is the optional initial date/time for the dialog in "yyyy-MM-dd HH:mm" format (default: now) options /D display and return Date only (default: date and time) /T display and return Time only (default: date and time) /I24 Ignore AM/PM in Input on systems with 24-hour format /O24 append AM/PM to Output on systems with 24-hour format /FT:"file" use File Timestamp of specified file for the dialog's initial date/time /DD:dateformat Date Display format (GUI) /DO:dateformat Date Output string format /TD:timeformat Time Display format (GUI) /TO:timeformat Time Output string format /DTO:datetimeformat Date and Time Output string format /DE:yyyy-MM-dd Earliest Date allowed /DL:yyyy-MM-dd Latest Date allowed /DMAX:numberofdays MAXimum Date allowed, relative to today, in days (negative number for a date in the past) /DMIN:numberofdays MINimum Date allowed, relative to today, in days (negative number for a date in the past) /H:height window Height (default: 135, minimum: 135, maximum: screen height) /I:index use Icon at index from shell32.dll /L[:captions] Localize or customize button captions (e.g. /L:"OK=Why Not?;Cancel=Never!") /W:width window Width (default: 220, minimum: 220, maximum: screen width) Example: Display date/time in default format, output in yyyyMMddHHmmssfff format (year, month, day, hours, minutes, seconds, milliseconds), selected date between today and 90 days in the future: DATETIMEBOX "When?" /DTO:yyyyMMddHHmmssfff /DMIN:0 /DMAX:90 Notes: Available custom date and time formats can be found on MSDN at: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx Note that by default AM/PM time formats ("tt" or "t") cannot be used on computers with a 24-hour time format. To prevent error messages, use /I24 to ignore "tt" or "t" (AM/PM) in specified input and/or output format, and /O24 to append AM/PM to the string on systems with 24-hour time format. If specified, the initial date/time must be in "yyyy-MM-dd HH:mm" or "yyyy-MM-dd HH:mm:ss" format; but with /D "yyyy-MM-dd" format is accepted, and with /T "HH:mm" and "HH:mm:ss" formats are accepted. If specified without captions, switch /L forces localized button captions (e.g. "Cancel" button caption is "Annuleren" on Dutch systems); if only a single custom caption is specified, the other one is localized (e.g. with /L:"OK=Gaan" on Dutch systems, "OK" button caption is "Gaan", "Cancel" button caption is "Annuleren"). The selected date and/or time are written to Standard Out if "OK" is clicked, otherwise an empty string is returned. Switches /D, /T and /DTO are mutually exclusive. Return code 0 for "OK", 1 for (command line) errors, 2 for "Cancel". Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Code to extract icons from Shell32.dll by Thomas Levesque: http://stackoverflow.com/questions/6873026 Written by Rob van der Woude http://www.robvanderwoude.com |
DATETIMEBOX.EXE /DD:yyyy-MM-dd DATETIMEBOX.EXE /D /DD:yyyy-MM-dd (TimePicker not shown when /D is used and vv.)DATETIMEBOX.EXE "When would be convenient?" "2016-01-01 09:30" /DD:MM/dd/yyyy /L:"Cancel=Never" /W:240 |
||||||||||||||||||||||||||||||||||||||||
DropDownBox |
|||||||||||||||||||||||||||||||||||||||||
Use DropDownBox.exe to present a list of choices, and return the selected one; like CHOICE with a GUI. You must enter a list of choices, separated by a delimiter. You can optionally add a prompt, set the window title, preselected item, and window dimensions, change the delimiter, and choose if you want the selected index to be returned as "ErrorLevel". The selected text is written to Standard Output. DropDownBox, Version 1.17 Batch tool to present a DropDown dialog and return the selected item Usage: DROPDOWNBOX "list" [ "prompt" [ "title" ] ] [ options ] or: DROPDOWNBOX /F:"listfile" [ "prompt" [ "title" ] ] [ options ] or: listcommand | DROPDOWNBOX [ "prompt" [ "title" ] ] [ options ] Where: "list" is the list of items to populate the dropdown control "listcommand" is a command whose standard output is used as a list of items to populate the dropdown control "prompt" is the optional text above the dropdown control (default: none) "title" is the window title (default: "DropDownBox, Version 1.17") Options: /C:index use iCon at index from shell32.dll (default: 23) /D:"delimiter" sets the Delimiter character for "list" (default: semicolon) /F:"listfile" use list from text File (one list item per line) /H:height sets the Height of the input box (default: 90; minimum: 90; maximum: screen height) /I:index sets the zero based Index of the preselected item (default: 0) /K sKip first item of list (e.g. a header line) /L[:"captions"] Localize or customize button captions (e.g. /L:"OK=Why Not?;Cancel=No Way!") /MF use Monospaced Font in prompt (default: proportional) /NM make dialog Non-Modal (default: modal, i.e. on top) /RI or /R1 Return code equals selected Index + 1, or 0 on (command line) errors or if "Cancel" was clicked (default: 0 on "OK", 1 on error, 2 on "Cancel") /RO or /R0 Return code equals selected 0-based index, or -1 on (command line) errors or if "Cancel" was clicked (default: 0 on "OK", 1 on error, 2 on "Cancel") /S Sort list (default: unsorted) /T:tablength sets the number of spaces for Tabs in prompt (4..16; default: 4) /W:width sets the Width of the input box (default: 200; minimum: 200; maximum: screen width) Notes: The selected item text is written to Standard Out if "OK" is clicked, otherwise an empty string is returned. Use either "list" or /F:"listfile" or "listcommand". Linefeeds (\n), tabs (\t) and doublequotes (\") are allowed in the prompt text (but not in the title); with tabs, /MF is recommended. If specified without captions, switch /L forces localized button captions (e.g. "Cancel" button caption is "Annuleren" on Dutch systems); if only a single custom caption is specified, the other one is localized (e.g. with /L:"OK=Gaan" on Dutch systems, "OK" button caption is "Gaan", "Cancel" button caption is "Annuleren"). Return code 0 for "OK", 1 for (command line) errors, 2 for "Cancel". With /RI return code equals selected index + 1, or 0 for "Cancel". With /RO return code equals selected index, or -1 for "Cancel". Command line switches /RI and /RO are mutually exclusive. Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Code to extract icons from Shell32.dll by Thomas Levesque: http://stackoverflow.com/questions/6873026 Written by Rob van der Woude http://www.robvanderwoude.comSample batch code, as used for the screenshot: DROPDOWNBOX "Amsterdam;London;Paris;Tokyo" "Choose a destination" "Destination" /I:1 /RI /C:13 >NUL An alternative with identical results would be to create a list file named "list.txt": Amsterdam and change the first command line to: DROPDOWNBOX /F:"list.txt" "Choose a destination" "Destination" /I:1 /RI /C:13 >NUL This may be useful for long lists, or for lists created on-the-fly. Finally, you can pipe lists to DropDownBox.exe's standard input, as is demonstrated in the following command to select a network printer (this is a single command line): WMIC.EXE Printer WHERE "Network=TRUE" Get Caption | DROPDOWNBOX.EXE "Select a network printer" "Network Printer" /K /S
|
|||||||||||||||||||||||||||||||||||||||||
RadioButtonBox |
|||||||||||||||||||||||||||||||||||||||||
Use RadioButtonBox.exe to present a list of choices grouped as radio buttons, and return the selected one; equivalent to DropDownBox.exe with radio buttons instead of a dropdown list. You must enter a list of choices, separated by a delimiter. You can optionally add a prompt, set the window title, preselected item, and window dimensions, change the delimiter, and choose if you want the selected index to be returned as "ErrorLevel". The selected text is written to Standard Output. RadioButtonBox, Version 1.01 Batch tool to present a Radio Button dialog and return the selected item Usage: RADIOBUTTONBOX "list" [ "prompt" [ "title" ] ] [ options ] or: RADIOBUTTONBOX /F:"listfile" [ "prompt" [ "title" ] ] [ options ] or: listcommand | RADIOBUTTONBOX [ "prompt" [ "title" ] ] [ options ] Where: "list" a list of items to populate the radio button group "listcommand" is a command whose standard output is used as a list of items to populate the radio button group "prompt" is the optional text above the radio button group (default: none) "title" is the window title (default: "RadioButtonBox, Version 1.01") Options: /A show Aliases for command line switches (see Notes) /C:columns sets then number of Columns for the radio button group (default: 1) /D:"delimiter" sets the Delimiter character for "list" (default: semicolon) /DE DEdup: remove duplicates from "list" /F:"listfile" use list from text File (one list item per line) /H:height sets the window Height (default: autosized to make content fit; minimum: 90; maximum: screen height - 68) /I:index use Icon at index from shell32.dll (default: 23) /K sKip first item of list (e.g. a header line) /L[:"captions"] Localize or customize button captions (e.g. /L:"OK=Why Not?;Cancel=No Way!") /MF use Monospaced Font in prompt (default: proportional) /NM make dialog Non-Modal (default: modal, i.e. on top) /P:index sets the zero based index of the Preselected item (default: 0) /R:rows sets then number of Rows for the radio button group (default: one row per list item) /RC0 Return Code equals selected 0-based index, or -1 on (command line) errors or if "Cancel" was clicked (default: 0 on "OK", 1 on error, 2 on "Cancel") /RC1 Return Code equals selected 1-based index, or 0 on (command line) errors or if "Cancel" was clicked (default: 0 on "OK", 1 on error, 2 on "Cancel") /S Sort list (default: unsorted) /T:tablength sets the number of spaces for Tabs in prompt (4..16; default: 4) /W:width sets the window Width (default: autosized to make content fit; minimum: 200; maximum: screen width - 16) Notes: The selected item text is written to Standard Out if "OK" is clicked, otherwise an empty string is returned. Most command line switches have one or more aliases, e.g. instead of /R:5 you can use /ROWS:5 to make your batch files more readable; use command line switch /A to get a list of all available aliases. Use either "list" or /F:"listfile" or "listcommand". Linefeeds (\n), tabs (\t) and doublequotes (\") are allowed in the prompt text (but not in the title); with tabs, /MF is recommended. To get a custom title without prompt, use " " for prompt. If specified without captions, switch /L forces localized button captions (e.g. "Cancel" button caption is "Annuleren" on Dutch systems); if only a single custom caption is specified, the other one is localized (e.g. with /L:"OK=Gaan" on Dutch systems, "OK" button caption is "Gaan", "Cancel" button caption is "Annuleren"). Return code 0 for "OK", 1 for (command line) errors, 2 for "Cancel". With /RC0 return code equals selected index, or -1 for "Cancel". With /RC1 return code equals selected index + 1, or 0 for "Cancel". Command line switches /RC0 and /RC1 are mutually exclusive. Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Code to extract icons from Shell32.dll by Thomas Levesque: http://stackoverflow.com/questions/6873026 Written by Rob van der Woude http://www.robvanderwoude.comOutput of RADIOBUTTONBOX.EXE /A command:
Switch Alias(es) ====== ========= /? /HELP /A /??, /???, /ALIAS or /ALIASES /C /COL, /COLS or /COLUMNS /D /DELIMITER /DE /DEDUP /F /FILE /H /HEIGHT /I /ICON /K /SKIP, /SKIPFIRST or /SKIPFIRSTITEM /L /LOCALIZED or /LOCALIZEDCAPTIONS /MF /MONO, /MONOSPACED or /MONOSPACEDFONT /NM /NONMODAL or /NON-MODAL /P /DEFAULT, /DEFAULTINDEX, /PRE, /PRESELECTED or /PRESELECTEDINDEX /R /ROWS /RC0 /RETURN0BASEDINDEX /RC1 /RETURN1BASEDINDEX /S /SORT or /SORTLIST /T /TAB or /TABLENGTH /W /WIDTH |
WMIC.EXE Printer WHERE "Local=TRUE" Get Caption | RADIOBUTTONBOX.EXE "Select a local printer" "Local Printer" /K /S /R:3 WMIC.EXE Printer WHERE "Local=TRUE AND NOT PrintProcessor='winprint'" Get DriverName | RADIOBUTTONBOX.EXE "Select a local physical printer" "Local Printer" /K /S /C:2 |
||||||||||||||||||||||||||||||||||||||||
MultipleChoiceBox |
|||||||||||||||||||||||||||||||||||||||||
Use MultipleChoiceBox.exe to present a list of choices grouped as checkboxess, and return the selected items; derived from RadioButtonBox.exe, but allowing multiple choices, hence its name. You must enter a list of choices, separated by a delimiter. You can optionally add a prompt, set the window title, preselected items, and window layout, or change the delimiter. The selected items are written to Standard Output. A binary represenation of the selected items is returned as "ErrorLevel": the errorlevel is 0 if no checkbox is checked, +1 if the first one is checked, +2 if the second one is checked, etcetera. RadioButtonBox, Version 1.00 Batch tool to present a Checkbox dialog and return the selected items Usage: MULTIPLECHOICEBOX "list" [ "prompt" [ "title" ] ] [ options ] or: MULTIPLECHOICEBOX /F:"listfile" [ "prompt" [ "title" ] ] [ options ] or: listcommand | MULTIPLECHOICEBOX [ "prompt" [ "title" ] ] [ options ] Where: "list" is a list of items to populate the checkbox group "listcommand" is a command whose standard output is used as a list of items to populate the checkbox group "prompt" is the optional text above the checkbox group (default: none) "title" is the window title (default: "MultipleChoiceBox, Version 1.00") Options: /A show Aliases for command line switches (see Notes) /C:columns sets the number of Columns for the checkbox group (default: 1) /D:"delimiter" sets the Delimiter character for "list" (default: semicolon) /DE DEdup: remove duplicates from "list" /F:"listfile" use list from text File (one list item per line) /H:height sets the window Height (default: autosized to make content fit; minimum: 90; maximum: screen height - 68) /I:index use Icon at index from shell32.dll (default: 23) /K sKip first item of list (e.g. a header line) /L[:"captions"] Localize or customize button captions (e.g. /L:"OK=Why Not?;Cancel=No Way!") /MF use Monospaced Font in prompt (default: proportional) /NM make dialog Non-Modal (default: modal, i.e. on top) /P:initial Preselect the initial checkboxes' state (see Notes) /R:rows sets then number of Rows for the checkbox group (default: one row per list item) /S Sort list (default: unsorted) /T:tablength sets the number of spaces for Tabs in prompt (4..16; default: 4) /W:width sets the window Width (default: autosized to make content fit; minimum: 200; maximum: screen width - 16) Notes: The selected item text is written to Standard Out if "OK" is clicked, otherwise an empty string is returned. Most command line switches have one or more aliases, e.g. instead of /R:5 you can use /ROWS:5 to make your batch files more readable; use command line switch /A to get a list of all available aliases. Use either "list" or /F:"listfile" or "listcommand". Linefeeds (\n), tabs (\t) and doublequotes (\") are allowed in the prompt text (but not in the title); with tabs, /MF is recommended. To get a custom title without prompt, use " " for prompt. If specified without captions, switch /L forces localized button captions (e.g. "Cancel" button caption is "Annuleren" on Dutch systems); if only a single custom caption is specified, the other one is localized (e.g. with /L:"OK=Gaan" on Dutch systems, "OK" button caption is "Gaan", "Cancel" button caption is "Annuleren"). Return code 0 for "OK", 1 for (command line) errors, 2 for "Cancel". With /P the inital state of each checkbox can be set; e.g. /P:5 wil set the 1st (1<<0 = 1) and 3rd (1<<2 = 4) checkboxes checked. Return code is a binary representation of the checked items, e.g. 5 (0101) if only the 1st and 3rd checkboxes were checked, -1 on errors. Be aware that the return code may be useless after sorting the list. Credits: On-the-fly form based on code by Gorkem Gencay on StackOverflow: http://stackoverflow.com/questions/17546909 Code to retrieve localized button captions by Martin Stoeckli: http://martinstoeckli.ch/csharp/csharp.html#windows_text_resources Code to extract icons from Shell32.dll by Thomas Levesque: http://stackoverflow.com/questions/6873026 Written by Rob van der Woude http://www.robvanderwoude.comOutput of MULTIPLECHOICEBOX.EXE /A command:
Switch Alias(es) ====== ========= /? /HELP /A /??, /???, /ALIAS or /ALIASES /C /COL, /COLS or /COLUMNS /D /DELIMITER /DE /DEDUP /F /FILE /H /HEIGHT /I /ICON /K /SKIP, /SKIPFIRST or /SKIPFIRSTITEM /L /LOCALIZED or /LOCALIZEDCAPTIONS /MF /MONO, /MONOSPACED or /MONOSPACEDFONT /NM /NONMODAL or /NON-MODAL /P /DEFAULT, /DEFAULTITEMS, /PRE, /PRESELECTED or /PRESELECTEDITEMS /R /ROWS /S /SORT or /SORTLIST /T /TAB or /TABLENGTH /W /WIDTH |
WMIC.EXE Printer WHERE "Local=TRUE" Get Caption | MULTIPLECHOICEBOX.EXE "Select local printers" "Local Printers" /K /S /C:2 /P:10 WMIC.EXE Printer WHERE "Local=TRUE AND NOT PrintProcessor='winprint'" Get DriverName | MULTIPLECHOICEBOX.EXE "Select local physical printers" "Local Printers" /K /S /C:2 /P:3 MULTIPLECHOICEBOX.EXE "Bungeejump from helicopter;Firewalk;Paraglide into an active volcano" "What is on your bucket list?" "Bucket List" /P:7 |
||||||||||||||||||||||||||||||||||||||||
ColorSelectBox |
|||||||||||||||||||||||||||||||||||||||||
Use ColorSelectBox.exe to present a color picker to select one of the available standard console colors. You can optionally set the color picker's window title. The selected color is written to Standard Output and returned as "ErrorLevel". ColorSelectBox, Version 1.00 Batch tool to present a color picker and return the selected (console) color Usage: COLORSELECTBOX [ "title" ] [ /R ] [ /T ] Where: "title" is the optional custom caption in the title bar (default: Pick a Console Color) /R return RGB value (R,G,B) of the selected color (default: single hexadcimal digit) /T Test: show console colors and their return values Notes: Only the 16 standard console colors are available. By default, the hexadecimal "index" of the selected console color is shown on screen (e.g. "C" for bright red) and returned as return code (e.g. 12 for bright red). With /R however, the RGB value of the selected color is shown (e.g. "255,0,0" for bright red) and returned as return code (i.e. 65536 x red + 256 x green + blue). With /T any other command line arguments will be ignored. With /T or if no selection is made or in case of (command line) errors, return code is -1. Written by Rob van der Woude http://www.robvanderwoude.comSample batch code to select both background and foreground color: @ECHO OFF |
|||||||||||||||||||||||||||||||||||||||||
FontSelectBox |
|||||||||||||||||||||||||||||||||||||||||
Use FontSelectBox.exe to present a font selection dialog. You can optionally enable several "bells and whistles" like color selection, effects (strikeout and underline) and charactersets. Several property values for the selected font are written to Standard Output; you can also specify a property to be returned as "ErrorLevel". FontSelectBox.exe, Version 1.01 Batch tool to present a Font Select dialog and return selected font properties Usage: FONTSELECTBOX [ fontname ] [ options ] [ /R:return ] Where: fontname initial font name (default: Courier New) Options: /I:size Initial font size (default: 12) /MAX:size Maximum font size (default: 48) /MIN:size Minimum font size (default: 6) /P:property show only the requested Property for the selected font on screen, instead of "all" properties; property can be "Name", "Size", "Style", "Color", "RGB" or "CharSet" /C allow Color change (requires /E) /E allow Effects (e.g. strikeout and underline) /H allow "script" fonts only, no symbols /S allow Script (character set) change /V allow Vector fonts /X allow fiXed pitch fonts only Return: default return code 0 on valid selection, -1 on cancel or error /R:C Return code equals selected Character set number /R:R Return code equals RGB value of selected color /R:S Return code equals selected font Size (rounded) /R:Y Return code equals selected stYle: Regular = 0, Bold + 1, Italic + 2, Underline + 4, Strikeout + 8 e.g. return code 7 means Bold + Italic + Underline Written by Rob van der Woude http://www.robvanderwoude.com |
|||||||||||||||||||||||||||||||||||||||||
ProgressBarGUI |
|||||||||||||||||||||||||||||||||||||||||
Use ProgressBarGUI.exe to present a customizable progress bar dialog. You can customize title and text, hide the scale values, change the range, etc. The program does not return a useful "ErrorLevel". Run ProgressBarGUI.exe /Samples to create 2 sample batch files, demonstrating the use of this program.ProgressBarGUI, Version 1.00 Batch tool to present a GUI style progress bar Usage: PROGRESSBARGUI.EXE [ options ] Options: /CAPTION:text optional text above the progress bar /DEBUG show actual value and progress in description /DESCRIPTION:text optional text underneath the progressbar /FILE:tempfile text file from which to read progress (default: progress.tmp in current directory) /HEIGHT:minimumheight minimum window height (default: 100) /INTERVAL:milliseconds progressbar refresh interval (deafult: 1000) /MAX:max maximum value for progress bar (default: 100) /MIN:min minimum value for progress bar (default: 0) /NOSCALE do not show min and max values next to progressbar (default: show values) /POS:"X,Y" X,Y position of dialog's top left corner (default: center dialog in screen) /SAMPLES write 2 sample batch files, demonstrating the use of this program, to the current directory. /TIMEOUT:seconds timeout after which program should exit, ready or not (1..86400, or 0 for no timeout, default: 3600 seconds = 1 hour) /TITLE:text dialog's window title /WIDTH:width dialog's window width (default: 600) Notes: The program reads the current value from a temporary file, as specified by the /FILE switch or the default "progress.tmp" in the current directory. If /DEBUG switch is used, /DESCRIPTION switch will be ignored. The /HEIGHT switch is not required: if text is added in caption or description, the dialog window height will automatically be resized to make it fit. The dialog window closes when either the temporary file no longer exists, or the timeout has elapsed, or the window is closed manually. Only one single instance of this program is allowed to run, an attempt to start a second instance will return an error message. Credits: Code to allow only single instance of program by michalczerwinski https://stackoverflow.com/a/6486341 Written by Rob van der Woude https://www.robvanderwoude.com |
|||||||||||||||||||||||||||||||||||||||||
SystemTrayMessage |
|||||||||||||||||||||||||||||||||||||||||
Unlike the previous dialog boxes, SystemTrayMessage.exe displays a tooltip message in the system tray's notification area. By default it starts displaying a tooltip which will be visible for 10 seconds (or any timeout specified), but the program will terminate immediately after starting the tooltip. The icon will remain in the notification area after the timeout elapsed, until the mouse pointer hovers over it. By using its optional /W switch, the program will wait for the user to click the message, or for the timeout to elapse, and then hide the icon before terminating.SystemTrayMessage.exe, Version 1.06 Display an icon in the system tray's notification area Usage: SystemTrayMessage.exe [ message ] [ options ] Where: message is the message text in the optional tooltip balloon Options: /I:icon tooltip Icon (Error, Info, None, Warning; default: Info) /L treat message as Literal text without interpreting escaped characters, e.g. show "\n" as literal "\n" instead of interpreting it as a newline character /P:path Path to an icon file or library (default: Shell32.dll) /S:index System tray icon index in icon library (default: 277) /T:title optional Title in the tooltip balloon /V:seconds number of seconds the tooltip balloon will remain Visible (default: 10) /W Wait for the timeout to elapse or for the user to click the message, then remove the icon from the notification area (default: exit without waiting) Notes: If no tooltip message is specified, switches /I, /L and /T will be ignored and no tooltip will be shown. By default, \n is interpreted as newline and \t as tab in message; in some cases this may lead to misinterpretations, e.g. when showing a path like "c:\temp"; either escape backslashes in paths or use /L to treat all message text as literal text. Command line switch /S will be ignored if switch /P specifies anything but an icon library. Use my Shell32Icons.exe to select a Shell32 icon and get its index. Return code ("ErrorLevel") is -1 in case of errors; with /W switch, return code is 2 if message balloon is clicked, or 3 if the timeout expired without clicking; otherwise return code is 0. Credits: Code to extract icons from Shell32.dll by Thomas Levesque http://stackoverflow.com/questions/6873026 Written by Rob van der Woude https://www.robvanderwoude.comSample batch code, as used for the screenshot: SET Message=It is time for your daily backup.\n |
Do you prefer ActiveX over command line? Try DialogLib by Søren Schimkat
Or test my new DialogBoxes.dll for COM-aware scripting languages.
page last modified: 2023-01-30; loaded in 0.0073 seconds