Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Windows 7, when I start the Command prompt, is there any command to display the contents of an environment variable (such as the JAVA_HOME or PATH variables)?

I have tried with echo $PATH, echo PATH and $PATH but none of these work.

share|improve this question
    
-1, as the most up voted and community-faq tagged topic in the environment-variables tag contains the answer, this questions does not show any research effort. –  Daniel Beck Oct 1 '11 at 10:39
8  
@Daniel: I know how to set environment variables in Windows, I simply open "System properties" > "Advanced" and "Environment Variables". So I don't expect the answer to my question in a question titled with "How do I set PATH and other environment variables?", because I know that! I'm not asking about how to set them. –  Jonas Oct 1 '11 at 12:00
    
In a way you're right - as one of the authors in the other topic, I haven't actually noticed the exact wording for a long time. I edited that topic to reflect its actual contents. I'm not going to change the vote though, both because I can't, and because I stand by my assessment that this topic shows no research effort. –  Daniel Beck Oct 1 '11 at 12:14

4 Answers 4

up vote 106 down vote accepted

In Windows Command-Prompt the syntax is echo %PATH%

To get a list of all environment variables enter the command set

To send those variables to a text file enter the command set > filename.txt

share|improve this answer
    
Why is this value different from what I've specified in computer properties? –  Johnny_D Sep 19 '13 at 9:45
2  
@Johnny_D It is likely that either you have a user scoped variable or you have a session scoped variable (using the set command inside a command prompt does not keep the change after you close the console window) that is overriding it. –  Scott Chamberlain Dec 7 '13 at 9:09
1  
@Johnny_D: You should ask that as a separate question by clicking the "Ask question" link at top right of page. –  RedGrittyBrick Dec 7 '13 at 10:17

From SET /?:

SET P

would display all variables that begin with the letter 'P'

So for example if you want to find value of environment variable %PATH%, you can just type set path.

This is 3 characters shorter than echo %PATH%, but note that it also lists other variables starting with "path" (e.g. PATHEXT).

share|improve this answer

Just type env and it will show all environment vars including PATH

share|improve this answer
    
Can you add a bit more information about how/why this works please? –  Chipperyman Mar 7 at 18:59
    
I really don't know the how/why. I just found it works in Win7 & OSX. According to Wikipedia "It is used to either print a list of environment variables or run another utility in an altered environment without having to modify the currently existing environment." –  skube Mar 7 at 20:16
2  
I get 'env' is not recognized as an internal or external command, operable program or batch file. –  Imray Aug 21 at 19:09

To complement the previous answer, if you're using Powershell echo %PATH% would not work. You need to use the following command instead: echo $Env:PATH

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.