Windows用户环境变量与系统环境变量 [英] Windows User Environment Variable vs System Environment Variable

查看:577
本文介绍了Windows用户环境变量与系统环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,是否有任何shell / Powershell命令单独列出用户环境变量和系统环境变量。如果我这样做 -

In Windows, is there any shell/Powershell command to list User Environment Variable and System Environment Variable separately. If I do -

SET TEMP

Windows显示用户环境变量,而不是Temp的系统变量。

Windows displays the User Environment Variable instead of System variable for Temp.

我正在寻找shell命令/ switch来单独显示这些变量。

I am looking for shell command/switch to display these variables separately.

推荐答案

在PowerShell中没有cmdlet,但您可以在Environment类中使用底层的.NET方法:

In PowerShell, there's no cmdlet for it, but you can use the underlying .NET methods in the Environment class:

Write-Host "Machine environment variables"
[Environment]::GetEnvironmentVariables("Machine")

Write-Host "User environment variables"
[Environment]::GetEnvironmentVariables("User")

# This should be the same as 'Get-ChildItem env:', although it isn't sorted.
Write-Host "Process environment variables"
[Environment]::GetEnvironmentVariables("Process")

这篇关于Windows用户环境变量与系统环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆