Qbasicnews.com

Full Version: PATH doesn't work within a DOS SHELL --- Why?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Quote:Nathan,
Ok, I tried your theory.

1) I created a batchfile which set the path to C:\MONEO.

2) I executed above batchfile from Windows by going to "My Computer", selecting the above batch file, and double click to run it. The screen went black for a second so it must have run it.

I think you didn't get me. You have to run your application from the BAT file as well, otherwise the changes in the environment variables will be lost: this is the code I posted, maybe you missed it 'cause it was the last post in page 1:

Code:
set path=C:\MONEO
LIST.EXE

Be sure to store this batch file in the same directory where LIST.EXE is.
That is really mysterious problem. What OS are you running? Perhaps this is a bug in the DOS Shell of such OS?
Quote:Nathan,
Ok, I tried your theory.

1) I created a batchfile which set the path to C:\MONEO.

2) I executed above batchfile from Windows by going to "My Computer", selecting the above batch file, and double click to run it. The screen went black for a second so it must have run it.

3) Again from "My Computer", I select what you call "my application" which is really an old version of the LIST utility. I double click to run it, pick a filename, Alt-G to go to DOS.

4) Now from the command-line of this DOS Shell, I do a PATH. Nope, it's the same old path as ever, not c:\moneo.

5) I think the reason that the up-front batchfile doesn't work is because I'm launching this "application" from Windows, which is exactly the idea behind all this. I need to do it this way.

Theres your problem dude. You are trying to change the environment in one DOS shell and expect it to last in another DOS shell.

Look, when you open a DOS shell and run the batch file, the environment of that particular shell(or DOS Box) is changed and the DOS shell is closed. So when you open another DOS box your changes arent going to show up in this one.

If you want to change the environment of each and every DOS shell then you can modify your environment using the msconfig.exe utility.
Thanks BigBasic, but Nathan and I are aware of that.

NATHAN, Just read your post about doing the path and invoking LIST in the same batchfile. It looks like it should work. Have you tried it? Gotta run, I'll try in tomorrow, thanks.
*****
So you're trying to change the path in a dos box and running a dos file in another one?

Well, if you are running W2000 or XP this won't work. There is no global environment. You get a new environment for every DOS box, straight from config.nt and autoexec.nt.

And for the path not changing in a shell, that's also Windows. To W2000 and XP all bat have an implicit ENDLOCAL at the end. See Windows help for ENDLOCAL

The good solution seems to be Nathan's one, change the shortcut to LIST.EXE to call a batch that first changes path then runs the program.
Something else...
Once you are in a program, your environmental variables are locked... the memory allocated for them is limited, and generally they cannot be changed.

Let me give an example... Lets say you have a qbasic program that runs and changes the environmental variable of "path". This is perfectly acceptable, and you can do it, however, the length of your new path cannot exceed the old one. Even more significant is that if you go to a shell from there, as far as I know, you cannot touch the env variables. This may be what is occuring... but I'll look into it.

Jonathan Simpson
Antoni:
Yeah, or else just change the starting environment for all DOS Boxes by editing autoexec.bat (or config.sys?)
Edited:
I suppose Moneo has more than one DOS PROGRAM in his PC so changing config.nt and autoexec.nt is not the solution...
more than one DOS?
NATHAN,
I did exactly what you said, executed a batchfile from Windows which first sets the path I need, then invokes the application (LIST) from which I then cause a DOS Shell. Once on the command-line I checked the path and it's the one I set before in the batchfile. You're a genius, Nathan.

I guess we'll really never know why a bathfile from the shell won't set the path. However, thanks to all you guys for your ideas and research. Big Grin
*****
Pages: 1 2 3 4 5