🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7964

Re: How do I change an enviroment var?

#7964
From: Mike Morris
Date: Thu, 07 Aug 1997 00:00
41 lines
2826 bytes
In article <33EA8504.49DA453@comtech.com.au> Grant Slender <grants@comtech.com.au> writes:
>From: Grant Slender <grants@comtech.com.au>
>Subject: How do I change an enviroment var?
>Date: Fri, 08 Aug 1997 12:31:32 +1000

>I need to get the list of current environment variables in a Dos based C
>program....I can do that using the "main( " argument lists....

>But how do I write a changed value back???

>Thanks for any tips

Since the running program inherits a duplicate set of the variables,
any changes get lost when the program exits back to DOS.

I got around that years ago with a very bad hack - my only excuse
is that it was a one-time program.

In the program I created and opened a file named $$!$$!$$.BAT,
and wrote a batch file into it.  It was two lines:

@SET VARAIBLE=FOO               <<-- make this line what you wnat to do.
@DEL $$!$$!$$.BAT               <<-- then delete the file that did it.

Before I exited my program, I poked the batch file name into the 
keyboard buffer. It worked.

There are better ways to do this but, but as I said, 
this was a quick one-time hack for a single-user system 
that I knew quite well.

Hoe that this stimulates the brain into thinking about alternative 
methods.


---------------------------------------------------------------------------
Mike Morris	ham radio: WA6ILQ     ICBM: 34:07:54.9 by 118:03:46.2
The above is my own opinion and should not be construed to be that of 
my former or my current employers.  Reply address spoofed to discourage 
junk email, please remove the "*" from the address.
Technical Details
Message-ID: <*morris*.1403.00457477@*cogent.*net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <33EA8504.49DA453@comtech.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f6aa,b241f3541a61f304,start
X-Google-Attributes: gid10f6aa,public
X-Google-Thread: f75c9,b241f3541a61f304,start
X-Google-Attributes: gidf75c9,public
X-Google-Thread: 104805,b241f3541a61f304,start
X-Google-Attributes: gid104805,public
X-Google-Thread: fc546,b241f3541a61f304,start
X-Google-Attributes: gidfc546,public
X-Google-Thread: 103f30,b241f3541a61f304,start
X-Google-Attributes: gid103f30,public
X-Google-Thread: 102bfa,b241f3541a61f304,start
X-Google-Attributes: gid102bfa,public
X-Google-Thread: 10b565,b241f3541a61f304,start
X-Google-Attributes: gid10b565,public
From: *morris*@*cogent.*net (Mike Morris)
Subject: Re: How do I change an enviroment var?
Date: 1997/08/07
Message-ID: <*morris*.1403.00457477@*cogent.*net>
X-Deja-AN: 262814671
References: <33EA8504.49DA453@comtech.com.au>
Organization: Organization? Not much around here...  Might lower the stress level...
Newsgroups: comp.os.msdos.programmer,unix-pc.general,it.comp.dos,it.comp.dos,abg.ms-dos,alt.msdos.batch,alt.msdos.programmer,backbone.fragen.dos,comp.msdos.programmer,comp.os.msdos,comp.os.msdos.programmer,comp.unix.dos-under-unix,de.comp.os.msdos,fr.comp