简体   繁体   English

如何从Powershell访问经常账户环境变量?

[英]How do I access the current account environment variables from powershell?

I am trying to track changes in my system as I install various programs. 安装各种程序时,我试图跟踪系统中的更改。 For example I have installed a few versions of python and kept checking my path variable which did not change. 例如,我已经安装了一些python版本,并一直检查我的path变量,该变量没有改变。 However my current account path did change. 但是,我当前的帐户路径确实发生了变化。 Without having admin rights a user can set environment variables for their account. 在没有管理员权限的情况下,用户可以为其帐户设置环境变量。 How can I see these with powershell? 我如何用powershell看到这些?

在此处输入图片说明

I'm looking for the User Variable Path highlighted in blue below, not the System variable named Path. 我正在寻找下面以蓝色突出显示的用户变量路径,而不是名为Path的系统变量。

在此处输入图片说明

For user's environment variables, use this: 对于用户的环境变量,请使用以下命令:

[Environment]::GetEnvironmentVariables("User")

Use either of the following for system's environment variables: 对系统的环境变量使用以下任一方法:

gci env:*
ls Env:
[Environment]::GetEnvironmentVariables("Machine")

For a particular variable: 对于特定变量:

[Environment]::GetEnvironmentVariable("PATH","Machine")
>>> import sys
>>> sys.path
['', 'C:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip', 'C:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs', 'C:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python36-32\\lib', 'C:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python36-32', 'C:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']
>>>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM