DOS Environment Variables

Eyer eyer at azu.informatik.uni-stuttgart.de
Wed May 8 22:52:20 AEST 1991


In article <42119 at cup.portal.com> robc at cup.portal.com (Rob X Cowan) writes:
>
>> Does anyone know how to permanently change a DOS environment variable from
>> within an executing program?  PUTENV() changes/creates a variable but it
>> is only in effect while the program is running.  As soon as I go back to
>> DOS, the environment is restored to its original variables.  I'm using
>> Turbo C.
>> 
>> Thanks for any help,
>> Rick Schatzman
>
>     I forgot to mention that int 2Eh (command.com interface) also has a
>way to actually access its own SET command.  Can't remember how right now,
>but it should be easier than direct access, if your not up to that.
>
>-Rob

The use of int 2Eh is following (I took it from Dave William's TechRef) :

entry   DS:DI   pointer to an ASCIIZ command line in the form :
                      count byte
                      ASCII string
                      carriage return
                      null byte

It is reported that this int will destroy all registers, including SP.

I wouldn't use this method, because it might *NOT* be suported by further
releases of DOS, and it is actually *NOT* supported by 4DOS. The other
thing is that the transient part of COMMAND.COM will be reloaded if necessary,
what is quite memory-wasting.

I would use the direct memory access : in your PSP (Programm Segment Prefix),
you will find the PSP of the father-process. You can so go up to the
command interpreter, even if it is not called COMMAND.COM (for instance 4DOS),
because it is his own father. And in the PSP, there is the pointer to the 
environment. So you can change the master environment.

Since I never tried this, I take no responsibility of what I wrote.

Manu  (Emmanuel Eyer)



More information about the Comp.lang.c mailing list