Variables in Windows command prompt

There are 2 types of variables.

  1. User defined
  2. Environment variables

Creating user defined variables

We can create new variables using set command.

set <variable-name>=<value>

set browser=chrome

To display the value of variable, you can use below command.

echo %<variable-name>%

For example – to view the variable “browser”, you can use below syntax.

echo %browser%

Viewing all environment variables

You can use “set” command to view all environment variables in Windows Command Prompt. Note that set command will shows user defined variables as well.

Some of the important environment variables are given below.

  1. %PATH%
  2. %WINDIR%
  3. %OS%


You may also like...