从命令行列出所有环境变量
是否可以从 Windows 命令提示符列出所有环境变量?
相当于 PowerShell 的 gci env:
(或 ls env:
或 dir env:
)。
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:
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
只需执行即可:
您还可以执行
SET prefix
来查看名称以prefix
开头的所有变量。例如,如果您只想从环境变量中读取 derbydb,请执行以下操作:
...您将得到以下内容:
Just do:
You can also do
SET prefix
to see all variables with names starting withprefix
.For example, if you want to read only derbydb from the environment variables, do the following:
...and you will get the following:
Jon 有正确的答案,但是用一些语法糖来详细说明一下..
使您可以一次一页地查看变量,而不是整个变量,或者
将输出发送到您可以打开的文件 output.txt在 记事本 或其他...
Jon has the right answer, but to elaborate a little more with some syntactic sugar..
enables you to see the variables one page at a time, rather than the whole lot, or
sends the output to a file output.txt which you can open in Notepad or whatever...
列出 PowerShell 中的所有环境变量:
或者按照 user797717 的建议以避免输出截断:
来源:创建和修改环境变量(Windows PowerShell 本周提示 )
To list all environment variables in PowerShell:
Or as suggested by user797717 to avoid output truncation:
Source: Creating and Modifying Environment Variables (Windows PowerShell Tip of the Week)
只需从
cmd 运行
。set
Simply run
set
fromcmd
.非扩展变量 -
用户变量 -
系统变量 -
扩展变量 -
在 CMD 中 -
在 Powershell 中 -
源 - https://devblogs.microsoft.com/scripting/powertip-use-windows-powershell-to-display-all-environment-variables/
Non expanded variables -
User variables -
System variables -
Expanded variables -
In CMD -
In Powershell -
Source - https://devblogs.microsoft.com/scripting/powertip-use-windows-powershell-to-display-all-environment-variables/
您可以在cmd中使用
SET
来显示当前变量,只需
SET
就足够了要显示某些变量,例如'PATH',请使用
SET PATH
。如需帮助,请输入
set /?
。You can use
SET
in cmdTo show the current variable, just
SET
is enoughTo show certain variable such as 'PATH', use
SET PATH
.For help, type
set /?
.不要浪费时间。在注册表中搜索:
返回小于SET命令。
Don't lose time. Search for it in the registry:
returns less than the SET command.
如果想看到刚刚设置的环境变量,需要打开一个新的命令窗口。
If you want to see the environment variable you just set, you need to open a new command window.