[FRPythoneers] env variable set using _winreg.SetValueEx() doesn't show w/ os.environ

Erick Bodine erick at allocity.com
Tue Dec 16 13:59:28 MST 2003

 am trying to set a new environment variable on a W2k machine with
only partial success.  The name("SSID") and value("ASIM") show up
correctly in the registry and when I go to "System
Properties"->Advanced->"Environment Variables".  However, if I open a
console and type 'set', "SSID" is not listed; also if I open a python
shell and do os.environ["SSID"] the variable is not found.  What am I
doing wrong???

import _winreg

system = r"SYSTEM\CurrentControlSet\Control\Session
registry = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
env_key = _winreg.OpenKey(registry, system, 0, _winreg.KEY_SET_VALUE)

key = "SSID"
value = "ASIM"

    _winreg.SetValueEx(env_key, key, 0, _winreg.REG_EXPAND_SZ, value)
except EnvironmentError:
    print "Encountered problems writing (%s) into the registry" % key


I have tried this using ActivePython-2.3.2-232 and Python-2.3.2 w/ the
same results.




"Every morning I read the obituaries; if my name's not there, I go to
- Anonymous

More information about the FRPythoneers mailing list