List all environment variables from command line?

ε祈祈猫儿з 提交于 2019-11-27 09:55:41
Jon

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
Fetchez la vache

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

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: https://technet.microsoft.com/en-us/library/ff730964.aspx

Simply run set from cmd.

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

Ievgen

I would say that SET command doesn't really print all environmental variables. For instance we can echo such variables as CD, DATE, TIME but they are not listed in SET output.

It would be interesting to get really whole list of variables that can be used for batch writing for example.

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

If you want to see the environment variable you just set, you need to open a new command window. "Variables set with setx variables are available in future command windows only, not in the current command window." (https://technet.microsoft.com/en-us/library/cc755104(v=ws.11).aspx#BKMK_examples)

don't lose time to search it in registry

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

returns less then set command

As mentioned in other threads you can use set to list all the environment variables or use

set [environment_varible] to get specific variable with value.

set [environment_varible]= can be use to remove variable from space.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!