Is it possible to distinguish between system environment variables and the user ones?

Kartic kartic.krishnamurthy at gmail.com
Tue Apr 5 19:37:04 EDT 2005


There is nothing that plainly differentiates whether an environment
variable is the system's or the current user's.

What you could do is:
1. Get the list of environment variables for the user the script is
executing as.
2. Use the pywin32 extensions to access the registry key
HKCU\Environment
3. Lookup the environment variables present in the list (Item 1)  that
appear as string values under HKCU\Environment.
4. The intersecting list belongs to the user, the rest can be surmised
as belonging to the system environment.

Thanks,
--Kartic




More information about the Python-list mailing list