The Computer Oracle

How can I display the contents of an environment variable from the command prompt in Windows 7?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 How Can I Display The Contents Of An Environment Variable From The Command Prompt In Windows 7?
00:24 Accepted Answer Score 868
00:52 Answer 2 Score 306
01:07 Answer 3 Score 17
01:33 Answer 4 Score 40
02:19 Thank you

--

Full question
https://superuser.com/questions/341192/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows7 #windows #commandline #environmentvariables

#avk47



ACCEPTED ANSWER

Score 868


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

To get a list of all environment variables enter the command set without any parameters.

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


Related




ANSWER 2

Score 306


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




ANSWER 3

Score 40


As an additional bit of information: While SET works with global or system variables, sometimes you want to write and read User variables, and this is done with the SETX command. SETX is included in the base installs of Windows beginning with Vista, but was also available in Windows XP by installing the Resource Pack.

One difference about SETX though is that you cannot read the variable out in the same command window you wrote it in. You have to write the SETX command in one Command or Powershell window, and then open a new window to read it using ECHO.

SETX can also write global or system variables.

To Set a user variable using SETX:

setx variable value

To set a global or system variable using SETX:

setx /m variable value

To read a user or global variable:

Remember, you must open a new Command or Powershell window to read this variable.

echo %variable%



ANSWER 4

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