Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting an environment variable

3 views
Skip to first unread message

Caesar Romano

unread,
May 19, 2009, 1:50:35 PM5/19/09
to
Hello,
Using lccwin32 on winxp, the SetEnvironmentVariable function sets the
value of an environment variable for the current process. Is there any
function that will set an environment variable that will persist after
the current process ends?

Thanks

glen herrmannsfeldt

unread,
May 19, 2009, 3:11:42 PM5/19/09
to
Caesar Romano <Sp...@uce.gov> wrote:

Note that this isn't a compiler (or library) question but
a system question. Does the system in question (XP) provide
any way for a program to do that?

In the few cases it is needed for unix (see tset for example) it
is done by returning the commands needed in the specified shell,
such that the user can get them executed.

In XP, the system control panel can set the value for
environment variables in new shells. That could probably also
be done through the registry editor. But that applies to new
shells, not currently running parent shells.

-- glen

Caesar Romano

unread,
May 19, 2009, 4:24:36 PM5/19/09
to
On Tue, 19 May 2009 19:11:42 +0000 (UTC), glen herrmannsfeldt
<g...@ugcs.caltech.edu> wrote Re Re: Setting an environment variable:

>Caesar Romano <Sp...@uce.gov> wrote:
>
>> Using lccwin32 on winxp, the SetEnvironmentVariable function sets the
>> value of an environment variable for the current process. Is there any
>> function that will set an environment variable that will persist after
>> the current process ends?
>
>Note that this isn't a compiler (or library) question but
>a system question. Does the system in question (XP) provide
>any way for a program to do that?

That's what I was wondering Glen. I've been looking through the WinAPI
documentation and haven't been able to find anything. I was wondering
if there was something that I missed.

Thanks for the reply.

glen herrmannsfeldt

unread,
May 19, 2009, 5:09:55 PM5/19/09
to
Caesar Romano <Sp...@uce.gov> wrote:
(snip)

<>Note that this isn't a compiler (or library) question but
<>a system question. Does the system in question (XP) provide
<>any way for a program to do that?

< That's what I was wondering Glen. I've been looking through the WinAPI
< documentation and haven't been able to find anything. I was wondering
< if there was something that I missed.

I don't believe so, but then I haven't looked so hard.

In DOS there was only one environment. I knew of people doing
multitasking with DOS, where changes in one would directly change
the environment of others.

As far as I know, in NT (and NT based systems like XP) they
followed the unix model of environment belonging to the task.

I suppose that doesn't preclude a "setparentenv" system
call, but if unix survives without one, Windows can, too.

< Thanks for the reply.

-- glen

ArarghMai...@not.at.arargh.com

unread,
May 19, 2009, 10:09:27 PM5/19/09
to
On Tue, 19 May 2009 21:09:55 +0000 (UTC), glen herrmannsfeldt
<g...@ugcs.caltech.edu> wrote:

<snip>


>
>I don't believe so, but then I haven't looked so hard.

I don't think so, either.

>In DOS there was only one environment.

Not really. There is 1 master environment, and any program that is
run, gets a COPY of that environment. Any changes made to the copy get
lost when the program ends. It is possible to make changes to the
master environment with third party software.


>I knew of people doing
>multitasking with DOS, where changes in one would directly change
>the environment of others.

<snip>
--
ArarghMail905 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the extra stuff from the reply address.

0 new messages