Purpose:Pops up a dialog box to get an input string from the user and save it in an environment variable


Format:QUERYBOX [/= /CUE="text" /D /E /Ln /P /POS=top,left /Tn] ["title"] prompt %%varname


titleText for the title bar of the dialog box.
promptText that will appear inside the dialog box.
varnameVariable name where the input will be saved.
/CUECue text to display in the input box


/D(igits only)


/E(dit existing value)

/POS (ition)

/L (maximum Length)



See also: INKEY, INPUT, and MSGBOX.




QUERYBOX displays a dialog box with a prompt, an optional title, and a string input field. Then it waits for your entry, and places any characters you type into an environment variable. QUERYBOX is normally used in batch files and aliases to get text input.


QUERYBOX is similar to INPUT, except it appears as a popup dialog box. If you prefer to work within the command line window, see the INKEY and INPUT commands.


The /CUE option displays the cue text in light gray in the input box (it disappears as soon as you enter a character).


Standard command line editing keys may be used to edit the input string as it is entered. All characters entered up to, but not including, the carriage return are stored in the variable.


If you press Ctrl-C or Ctrl-Break while QUERYBOX is waiting for input, execution of an alias will be terminated, and execution of a batch file will be suspended while you are asked whether to cancel the batch job. A batch file can handle Ctrl-C and Ctrl-Break itself with ON BREAK.


QUERYBOX returns a value of zero in the internal variable %_? after a successful operation, and a non-zero value otherwise (a timeout returns 20, a cancel returns 2). Be sure to save the return value in another variable or test it immediately; because the value of %_? changes with every internal command.


If you don't enter any arguments, QUERYBOX will display its command dialog.




To prompt for a string and store it in the variable NAME:


querybox "File Name" Enter a name:  %%name




/=Display the QUERYBOX command dialog to help you set the command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.


/DOnly accepts numeric values.


/EAllows you to edit an existing value. If there is no existing value for varname, QUERYBOX allows you to enter a new value.


/Ln Sets the maximum number of characters which QUERYBOX will accept to n.


/PTells QUERYBOX to echo asterisks, instead of the characters you type.


/POSSets the dialog position. (If you don't specify a position, QUERYBOX will center the dialog in the TCC window.


/TnWait for a maximum of n seconds for a response.