Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!sol.ctr.columbia.edu!ira.uka.de!ifistg!eyer@azu.informatik.uni-stuttgart.de From: eyer@azu.informatik.uni-stuttgart.de (Eyer) Newsgroups: comp.lang.c Subject: Re: DOS Environment Variables Summary: Use of int 2Eh Keywords: SET int 2Eh Message-ID: <10519@ifi.informatik.uni-stuttgart.de> Date: 8 May 91 12:52:20 GMT References: <91125.051531AURPS@ASUACAD.BITNET> <42119@cup.portal.com> Sender: news@ifistg.uucp Organization: Informatik, Uni Stuttgart, W. Germany Lines: 41 In article <42119@cup.portal.com> robc@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)