SET command

The SET command can display, set, or remove environment variables that can be later retrieved through variable expansion.

Synopsis - Simple set

SET variable[=[content]]

Assign content to variable variable. If content is not specified, the the variable variable is removed from the environment.

If neither the equal sign nor content are specified, SET will list variables which name begin with variable and their content.

The way SET deals with quotes and spaces is a bit special and inherited from cmd’s SET behaviour:

Synopsis - Arithmetic evaluation

SET /a variable=expression

Computes the value of the arithmetical expression expression and assign its value to variable variable. This command behaviour depends on mode set through SETLOCAL command (parameter ENABLEFLOATS).

To get extended help about arithmetical expressions, please see the dedicated manual page for SET /a command.

Synopsis - Prompting inputs

SET /p variable=question

Prompts question, And waits for an input from user and assign it to variable.

Note that thank to pBat method of handling pipes, SET /p can be used to store the output of a command in a variable (here output) by using the following method:

command | SET /p output=

See also

Command list, ECHO command, PAUSE command, SET /a command.