简体   繁体   中英

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. 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?

在此处输入图片说明

I'm looking for the User Variable Path highlighted in blue below, not the System variable named 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']
>>>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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