Windows用户环境变量与系统环境变量 [英] Windows user environment variable vs. system environment variable

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

问题描述

在Windows中,是否有任何shell/PowerShell命令分别列出用户环境变量和系统环境变量?

In Windows, is there any shell/PowerShell command to list user environment variable and system environment variable separately?

如果我愿意-

SET TEMP

Windows显示用户环境变量而不是TEMP的系统变量.

Windows displays the user environment variable instead of system variable for TEMP.

我正在寻找一个shell命令/开关来分别显示这些变量.

I am looking for a 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天全站免登陆