Modifying the environment

Dirck Blaskey dirck.IsGettingTooMuchSpam at
Thu May 25 22:32:22 EDT 2000

Daley, MarkX <markx.daley at> wrote in message
news:75F7304BB41CD411B06600A0C98414FC0A415B at ORSMSX54...
> Here is a subject someone has to have covered at one time.  How do I modify
> the environment using Python in such a way that the changes stay after the
> Python script executes?  I'm sure there's a way, I just haven't uncovered it
> yet.  If I use os.environ or os.putenv(), the changes only last as long as I
> remain in Python.  Even the DOS window protects it's own copy of the
> environment!

Assuming you are running Win32 of one form or another;

Under NT the environment variables are stored in the Registry
(in more than one place)

Under 95 there is a system utility 'winset', for setting environment
variables (I haven't tried this):

This stuff should be wrap-able for Python.

More information about the Python-list mailing list