Page 1 of 1

Environment Variables

Posted: Fri May 05, 2006 4:22 am
by Bulwark
Win XP Home SP.2 QBasic 4.5

After running the following code why does filenam not appear in the list of Environment Variables please - the path\file do exist.

Code: Select all


cls
shell "if exist c:\windows\system32\eula.txt set filenam=yes"

I = 1
do while environ$(I) > ""
   print environ$(I) 
   I = I + 1
loop


Posted: Fri May 05, 2006 6:51 am
by Z!re
Because shell creates a new local copy of the shell environment, and sets thefilenam variable there.
Then the shell is closed, and the environment for that shell is lost.

To do what you want you have to set the filenam in the same shell as the program is executed in. A batfile to start it works.

Posted: Fri May 05, 2006 4:37 pm
by Patz QuickBASIC Creations
Thats what DOS emulation does for you. (because Windows NT based-OSes are not based on DOS, but the NT kernel.)

Posted: Wed May 10, 2006 12:11 pm
by Zim
It's done the same thing since DOS version 2.1. I speak from experience.

Thanks to all

Posted: Thu May 11, 2006 9:51 pm
by Bulwark
And sorry for the delay in getting back to you.

I couldn't figger out a workaround so now echo to a file to pass the info to the program.

B...

Posted: Fri May 12, 2006 9:24 am
by Antoni
Just do a batch file that runs the program that changes the environment, then the program that requires the new environment in the same DOS window.
If you close the window the changes will be lost, and they won't affect to a different DOS window.