List all environment variables from command line?

2019-01-09 21:05发布

I'd like to know if it's possible to list ALL environment variables from Windows' Command Prompt.

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

9条回答
Rolldiameter
2楼-- · 2019-01-09 21:14

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.

查看更多
成全新的幸福
3楼-- · 2019-01-09 21:23

To list all environment variables in Powershell:

Get-ChildItem Env:

Source: https://technet.microsoft.com/en-us/library/ff730964.aspx

查看更多
Anthone
4楼-- · 2019-01-09 21:25

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)

查看更多
做自己的国王
5楼-- · 2019-01-09 21:26

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
查看更多
啃猪蹄的小仙女
6楼-- · 2019-01-09 21:31

Simply run set from cmd.

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

查看更多
唯我独甜
7楼-- · 2019-01-09 21:31

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.

查看更多
登录 后发表回答