Get environment variable for current user and for all Python users

Is there a way to determine which environment variables returned os.environbelong to the current user, and which to all users? I do not want to change it, I just get it.

UPD: I am using Microsoft Windows 7.

+4
source share
1 answer

I don't think you can figure it out using standard Python, for example os.environ. The only way to get user and system variables in Windows is to use the registry, you can find more here :

HKEY_CURRENT_USER\Environment

System variables

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

User variables

You need to access the registry with Python in order to get them.

+1
source

All Articles