Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all environment variables from the command line

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:).

like image 850
Nicola Cossu Avatar asked Mar 16 '11 15:03

Nicola Cossu


People also ask

How can I see all variables in CMD?

Select Start > All Programs > Accessories > Command Prompt. In the command window that opens, enter set. A list of all the environment variables that are set is displayed in the command window.

What command displays environment variables?

The most used command to displays the environment variables is printenv . If the name of the variable is passed as an argument to the command, only the value of that variable is displayed.

How do I list all environment variables in PowerShell?

Environment variables in PowerShell are stored as PS drive (Env: ). To retrieve all the environment variables stored in the OS you can use the below command. You can also use dir env: command to retrieve all environment variables and values.


2 Answers

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 
like image 128
Jon Avatar answered Oct 07 '22 21:10

Jon


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...

like image 21
Fetchez la vache Avatar answered Oct 07 '22 21:10

Fetchez la vache