How to display all environment variables at the Windows command prompt
March 16, 2021
This article will show you how to display all environment variables from the Windows command line.
PowerShell and CMD
First of all, you need to distinguish what kind of program you are working in. The first appeared CMD - Windows command line, shell. For many years, CMD was the only option for running on the Windows command line.
Then PowerShell came along. In the beginning, it was an environment that could be specially launched. In recent years, PowerShell has become more common, in the “Power User Menu”, which is invoked by the Win+x keyboard shortcut, PowerShell has replaced CMD. Also, the new Terminal uses PowerShell by default.
The commands for displaying all environment variables depend on whether you are in PowerShell or CMD, so you need to differentiate between them.
PowerShell looks like this:
Or like this:
That is, the command line prompt begins with “PS”.
And the CMD looks like this:
Or like this:
How to list all environment variables in PowerShell
In PowerShell, use one of the following commands:
gci env: ls env: dir env:
They are not only equivalent, in fact, they are just aliases for the same command. That is, there is no difference in their use.
How to display all environment variables in CMD
To display environment variables in CMD use the command:
To cut the output in one screen with the ability to scroll through the list, use the following construction:
SET | more
To save the output to a file:
SET > output.txt
This text file, output.txt, can be opened in any editor such as Notepad.
To display the value of a specific variable, use the familiar set command with the variable name:
The set command prints the value of all variables that start with the line VARIABLE. For example, the previous command will print the values of the PATH and PATHEXT variables.
And the following command will print the values of all variables whose name begins with P:
Note that command names on Windows are not case sensitive.
- ImageMagick error on Windows: “magick: unable to open image ''test': No such file or directory @ error/blob.c/OpenBlob/3565. magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/741.” (SOLVED) (76.8%)
- Basics of launching and using command line utilities in Windows (75.5%)
- Tor environment variables (73.2%)
- How to manage services on Windows (61.4%)
- How to install the latest PowerShell on Windows 11 (61.4%)
- How to convert .webp images to GIMP (RANDOM - 50%)