Environment variables in Windows 2000

Tim Daneliuk tundra at tundraware.com
Sat Nov 24 20:10:06 CET 2001


Tim Roberts wrote:
> 
> "Brian Geddes" <brian.j.geddes at intel.com> wrote:
> >
> >I've been trying to store/pass information in environment variables in
> >Windows 2000, but things aren't working the way I expect them to.
> 
> The short and rather unsatisfactory answer is that you just cannot do this
> in a Win32 application.  You cannot change an environment variable in a
> Win32 program in a way that outlives the process (except for the registry
> hack mentioned earlier, which affects ALL processes from that point
> forward).  You can affect the environment in your CHILD processes, but not
> in your SIBLINGS.
> --
> - Tim Roberts, timr at probo.com
>   Providenza & Boekelheide, Inc.

I dunno why this is "unsatisfactory" - you cannot do this in Unix either -
that is, you cannot modify an environment variable which persists to other
login instances (and therefore, shell instances).  The only way to
get global environment settings is to change the appropriate shell global
startup files.

This is not a problem,  but an intentional design point in both operating
systems.  You do not want a random user process to be able to fiddle with
the runtime environments of other users.  This is intentionally possible
only by an act of system administration...

It is a bit unclear exactly what the original poster was trying to
accomplish, but both pipes and files are probably a more appropriate
IPC mechanism for asynchronously invoked processes than environment variables,
at least if those processes need to be started by different users and across
different login instances.
-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com



More information about the Python-list mailing list