Luke Dunstan wrote:
> >From: ERIC KRAUSE (ekraus02) <ekraus02@...>
> >To: <taupind@...>
> >CC: <mingw-users@...>
> >Subject: Re: [Mingw-users] putenv(...) and system(...)
> >Date: Wed, 18 Sep 2002 15:02:44 -0400
> >Daniel Taupin writes:
> > > If, inside a program XXX, I code
> > >
> > > putenv("set environt_var=its_value");
> > >
> > > and then
> > >
> > > system("some-program.exe");
> > >
> > > will the program some-program.exe have "environt_var" set to the
> > > specified value?
> >Sorry--it will not; see answer to second question for the reason this
> >doesn't work.
> Sorry, it *will* work. Have you actually tried it? I just did, and this is
> the whole point of the putenv() function. If your answer was based solely on
> the MSDN documentation, it is trying to express that you can't set a
> "global" environment variable this way that will be visible to non-child
> processes. Read the rest of that paragraph:
> "However, the modified environment can be passed to any new processes
> created by _spawn, _exec, or system, and these new processes get any new
> items added by _putenv and _wputenv."
Oups. I do want to pass the new environment to the Child I invoke
through the next system() after purenv(), but I definitely want that
change to be LOCAL to that child (and possibly to the father) but NOT to
any otehr process which could be launched!
Let me explain: I wan to lanch a program (whatever) with a special
environment, but only THAT program.
This is intended to permit the Windows User to launch and execution with
a specified environment, or another environment. The purpose is to have
the possibility of running programs of various versions (i.e. various
environment and PATHs), without any interference between versions.
> > > Second question: will the variable "environt_var" stay at "its_value"
> > > when XXX has terminated.
> >No it does not--_putenv simply modifies that program's environment, and
> >not affect the environment of any other process, including the command-line
> Yes, except child processes.
> >Hope this helps.
> >Eric R. Krause
> Luke Dunstan
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
Daniel Taupin, 91400 ORSAY - France
Home/fax: (33)184.108.40.206.44. Rep.: (33)1.60.10.04.13, fax (work)