Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!uwvax!oddjob!gargoyle!ihnp4!ihlpe!psfales From: psfales@ihlpe.ATT.COM (Pete Fales) Newsgroups: comp.sys.ibm.pc Subject: Re: Environment settings from a C program Message-ID: <2168@ihlpe.ATT.COM> Date: Mon, 12-Oct-87 11:00:42 EDT Article-I.D.: ihlpe.2168 Posted: Mon Oct 12 11:00:42 1987 Date-Received: Tue, 13-Oct-87 06:50:45 EDT References: <700@hsi.UUCP> <114@fxgrp.UUCP> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 64 Keywords: ms-dos environ putenv getenv turboc In article <114@fxgrp.UUCP>, ljz@fxgrp.UUCP (Lloyd Zusman) writes: > 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? > > > Sorry, but what you want to do isn't possible. DOS (be it MSDOS or PCDOS) ^^^^^^^^^^^^^^ > is written such that no running program can change the environment of its > parent. In case you need more explanation, consider this: > This is rather strong language for an operating system with no memory protection. I have 512 byte program downloaded from a bulletin board called SETVAR.COM that does exactly that. You type SETVAR XXX and one line of standard input is put into XXX in the PARENT environment. I don't know how it works, but it is really nifty. It provides many of the same functions as back-quote substitution under UNIX. Since the file is small, and news won't let me post this article without more text, here is the uuencoded SETVAR.ARC. begin 644 SETVAR.ARC M&@A3151605(N0T]- 2^0@$ "8*E$H"^P " ,Z0H!@%3@ST! *[8I\@ ( MP*!] >H,2(Z&"Q)-+T MZ9-%#C+ZZCC 1L9^\TS5\7:DJ=8!%C*B:P3 A(X"=1(LVF?"6 $ ZRQ K#H M'MBI*YXQ N8(VUY^\T@Q0M9XZ>$ N #4W5& CH$CXO"M@S*XK(20! ^0#0T6#$ MR")O3\&*%00 ,JE%\Q8IBY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