Advertisement
Advertisement


List all environment variables from the command line


Question

Is it possible to list all environment variables from a Windows' command prompt?

Something equivalent to PowerShell's gci env: (or ls env: or dir env:).

2020/04/27
1
950
4/27/2020 12:11:40 PM

Accepted Answer

Just do:

SET

You can also do SET prefix to see all variables with names starting with prefix.

For example, if you want to read only derbydb from the environment variables, do the following:

set derby 

...and you will get the following:

DERBY_HOME=c:\Users\amro-a\Desktop\db-derby-10.10.1.1-bin\db-derby-10.10.1.1-bin
2019/09/26
1378
9/26/2019 8:41:10 AM

Jon has the right answer, but to elaborate a little more with some syntactic sugar..

SET | more

enables you to see the variables one page at a time, rather than the whole lot, or

SET > output.txt

sends the output to a file output.txt which you can open in Notepad or whatever...

2019/09/26

To list all environment variables in PowerShell:

Get-ChildItem Env:

Or as suggested by user797717 to avoid output truncation:

Get-ChildItem Env: | Format-Table -Wrap -AutoSize

Source: Creating and Modifying Environment Variables (Windows PowerShell Tip of the Week)

2019/09/26

Simply run set from cmd.

Displays, sets, or removes environment variables. Used without parameters, set displays the current environment settings.

2013/07/10

You can use SET in cmd

To show the current variable, just SET is enough

To show certain variable such as 'PATH', use SET PATH.

For help, type set /?.

2015/01/13

Don't lose time. Search for it in the registry:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

returns less than the SET command.

2019/09/26

Source: https://stackoverflow.com/questions/5327495
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]