Batch File Variables


Declaration

Variables are declared with the set [[Batch/BuiltinCommands#Set|builtin.

set foo=bar


Usage

Variables are accessed by their name. A percent sign (%) must surround the name.

set bar=%foo%

If a variable's value includes a character that the shell will interpret specially, quote the variable.

set bar="%foo%"

If a variable is not set, no substitution occurs.

set MyVar=
echo %MyVar% # '%MyVar%'


CategoryRicottone