Knowing the environment variables in your platform is a must when you are developing or administrating a system. In this post, I will show you the possible ways to list all environment variables in Windows.
Open a new command prompt (
Win+R, then type
cmd and hit enter) and type:
The command outputs a list of all the environment variable names and values separated by an equal sign (=).
You can also filter the output by typing:
set | findstr "PATH"
The command now outputs the same list but only shows the environment variables that contain the word PATH.
PowerShell is the new command line interface for Windows. It is much more powerful than the old
PowerShell offers multiple ways to list all environment variables. The easiest one is to use the
Open a new PowerShell prompt (
Win+R, then type
powershell and hit enter) and type:
The command outputs a list of all the environment variable names and values in a table format.
Get-ChildItem is a bit long, so PowerShell offers some aliases to make it easier to use.
You can use any of the following commands to get the same result:
The command outputs the same as the
Get-ChildItem Env: command.
The main advantage of the PowerShell approach is that you can provide many options to the cmdlet to customize its output for your needs.
PowerShell is shipped with most of the modern Windows Versions.
If you are running Microsoft Windows XP, you can set it up by installing MS .NET Framework 2.0 SP2 for Win2000 SP4, XP SP2/SP3 & Server 2003 SP2, and then Microsoft Windows PowerShell 1.0 for Windows XP.
If you don't need to use this output in a script, or you just prefer to use the Windows GUI, you can check the environment variables from the System Properties window.
Win+R keys, type
sysdm.cpl and hit enter.
Next, click on the Advanced tab and then on the Environment Variables button.
The Environment Variables dialog will open. You can see the list of all environment variables for the current user and the system.
In this post, I have shown you the possible ways to list all environment variables in Windows.
From the command line using
cmd.exe or the new
PowerShell, to the plain old Windows GUI.
I hope you find it useful.