Set Windows Environment Variable

Fredrik Lundh fredrik at pythonware.com
Thu Mar 30 12:29:38 EST 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:

http://msdn.microsoft.com/library/en-us/dllproc/base/environment_variables.asp

(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).

</F>






More information about the Python-list mailing list