DOS Environment Variables

Andy DeFaria defaria at hpcupt3.cup.hp.com
Fri May 10 13:51:23 AEST 1991


>/ hpcupt3:comp.lang.c / AURPS at ASUACAD.BITNET /  5:15 am  May  5, 1991 /
>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.

My understanding is that you have to change the "master environment" by
walking back the PSP (or something like that).  I had gotten some Turbo Pascal
code to do this but I recall some big problems with this whole approach and I
abandoned it.  It had something to do with the face that if you try to change
an existing environment variables value then the new value can't be larger
that the old value and if it is a new environment variable then you have to be
careful about running out of environment space (and there is only a couple of
bytes of extra environment space).

Like I said I could dig up the information if you like.



More information about the Comp.lang.c mailing list