frush@longs.LANCE.ColoState.Edu (Raymond Frush) (11/24/90)
Hello- I am looking for someone to send me information about how to perminantly set DOS environment variables from within a C program, so that when the program finishes, the variable remains set. I realize that it has to do with finding the location of the environment stored in memory, but have no clue to go about finding it. E-Mail responses please. Thanks! /------- You have been reached by...-------------+--------------------\ | Raymond Frush at Colorado State University | But, don't take my | | Center for Computer Assisted Engineering | word for it... | | ARPA frush@longs.LANCE.colostate.edu | | |------------------------------------------------+--------------------| | UUCP:..ncar!boulder!ccncsu!longs.lance.colostate.edu!frush | \------------------------------------------------+--------------------/
Valenti@MSU (John Valenti) (02/06/91)
I'm told that a program is given a copy of the environment variables, so any changes/additions made are lost when the program ends. There must be some way around this limitation? Specifically, I want a batch file that runs a Quick C program, then calls another batch file based on an environment variable: :top menu (quick c program) if %prgm%=exit goto done call %prgm% goto top :done (The above batch file may not be syntactically correct, but you get the idea?) Any leads on permanently setting env. variables in the DOS shell that called the Quick C program are appreciated. Thanks, John Valenti Valenti@msu.edu
av@kielo.uta.fi (Arto V. Viitanen) (02/06/91)
>>>>> On 5 Feb 91 23:05:10 GMT, Valenti@MSU (John Valenti) said:
John> I'm told that a program is given a copy of the environment variables, so any
John> changes/additions made are lost when the program ends. There must be some
John> way around this limitation?
John> Specifically, I want a batch file that runs a Quick C program, then calls another batch
John> file based on an environment variable:
John> :top
John> menu (quick c program)
John> if %prgm%=exit goto done
John> call %prgm%
John> goto top
John> :done
John> (The above batch file may not be syntactically correct, but you get the idea?)
There is (for some DOS versio) some undocumented interrupt, which does
exactly that. You should check it from a list of MSDOS interrupts (at
simtel20 and garbo.uwasa.fi, I think).
If number is enough for your menu system, why don't you use exit() plus
ERRORLEVEL ? For example, if your menu has seven different choises, your
program has
choise = get_user_selection();
exit(choise);
and your batchfile has
:top
menu
IF ERRORLEVEL 7 goto seven
IF ERRORLEVEL 6 goto six
..
IF ERRORLEVEL 0 goto zero
:six
program_six
goto top
notice the order: from high to low !
Hope this helps
--
Arto V. Viitanen email: av@kielo.uta.fi
University Of Tampere, av@ohdake.cs.uta.fi
Finland