Set Windows Environment Variable

Fredrik Lundh fredrik at
Thu Mar 30 19:29:38 CEST 2006

Fuzzyman wrote:

> I *believe* that ``SetEnvironmentVariable`` exists in the underlying
> windows API, but that it isn't wrapped by the win32api extension.

SetEnvironmentVariable does the same thing as assignment to os.environ.

The only way to set the environment for another process is to create the
process yourself, and pass in an environment block.

To modify the system environment, you need to update the registry and
broadcast a window message; see:

(that cannot be used to modify the environment for arbitrary processes,
though.  it's up to each process to decide how to handle that message,
if it cares about window messages at all).


More information about the Python-list mailing list