Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!ssc-vax!bcsaic!paula From: paula@bcsaic.UUCP (Paul Allen) Newsgroups: comp.sys.ibm.pc Subject: Re: Environment settings from a C program Message-ID: <2400@bcsaic.UUCP> Date: Wed, 14-Oct-87 20:29:29 EDT Article-I.D.: bcsaic.2400 Posted: Wed Oct 14 20:29:29 1987 Date-Received: Sat, 17-Oct-87 17:38:04 EDT References: <700@hsi.UUCP> Reply-To: paula@bcsaic.UUCP (Paul Allen) Organization: Boeing Computer Services AI Center, Seattle Lines: 31 Keywords: ms-dos environ putenv getenv turboc In article <700@hsi.UUCP>, mark@hsi.UUCP (Mark Sicignano) writes: >I am trying to change an environment variable from within >a Turbo-C program. Turbo-C provides a function, putenv() >which will make changes to, add, or delete environment, >but any changes are made to the environment within the program, >and for child processes. > >I need for these changes to remain. Is it possible? I've seen several responses to this, ranging from "It's impossible" to "here's a PD program that does it". So far, noone has mentioned undocumented interrupt 1EH. This interrupt takes as an argument a pointer to a string containing a command to be executed by command.com. The first byte of the string is a count of the remaining bytes. If you pass it "set foo=bar", it will set the variable foo in command.com's environment space. A little thought will turn up all sorts of nifty uses for this capability. In fact, one of my unfinished projects at home is a little program that understands commands like !!, history, and alias, and passes everything it doesn't understand off to command.com. Caveats: I have used this undocumented feature, and it works, but it is probably undocumented for a reason. I am working from memory, or I could tell you which register to put the string address in. If you really want it, e-mail me. Or check Ray Duncan's column in back issues of Dr. Dobb's or the Best of BIX column in back issues of BYTE. Paul Allen paula@boeing.com ...!uw-beaver!ssc-vax!bcsaic!paula