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
I'm defining a DOS Shell as the state you are in when a program you're running lets you "go to DOS", or you're in Basic and you issue a SHELL command with no operand. You end up on the DOS command line, and when you're done you must type EXIT. This is similar, but not exactly the same, as "going to a DOS prompt or DOS command" from Windows.

I was doing some testing when in a DOS Shell, and found that during my limited testing, almost everything works the same as if you were in a totally DOS machine or if you were at a Windows DOS prompt or command.

What didn't work? I made a batchfile that contained a TYPE, ECHO and a PATH command. The TYPE and ECHO worked fine, but the PATH commmand to change the current PATH did not work at all. I tried several versions, but it ignores this PATH command inside a batchfile. I tried the PATH command from the command line, and it works fine, changing the PATH. BTW, PATH commands do work from a batchfile on a DOS machine or a Windows DOS prompt.

Ok, does anybody know what's so special about performing a PATH command from inside a batchfile when in a DOS Shell?
*****
Remember when you open a SHELL you get a copy of the environment, so what you do there does'nt affect the environment vars used by qb. When shell closes all your changes are lost
Its the same reason why you can't recover the return value from a program run in a shell.

So the question is how do you check if the path changes were made? You should check from inside the same shell...
Urm...if you are trying to change the path just use the CHDIR command. no need to open a shell.
Quote:Remember when you open a SHELL you get a copy of the environment, so what you do there does'nt affect the environment vars used by qb. When shell closes all your changes are lost
Its the same reason why you can't recover the return value from a program run in a shell.

So the question is how do you check if the path changes were made? You should check from inside the same shell...
Hi Antoni, haven't heard from you in a while.
I think you missed my point. I'll re-phrase the problem:
* I'm in a DOS Shell, and on the command-line.
* If I do a PATH from the command-line IT DOES TAKE EFFECT OK.
* However, if I create a batchfile with a PATH command, and execute the batchfile from the command-line while being in the same DOS Shell, IT IGNORES THIS PATH COMMAND --- WHY?
*****
Moneo, when u launch the batch file, it gets executed in a different shell (i think) so the path is changed but inside the batch file's shell and not the exe which launched it =P.
Quote:Urm...if you are trying to change the path just use the CHDIR command. no need to open a shell.
I'm opening a Shell for very specific reasons which I won't get into right now.
A CHDIR or CD command is to change or reposition you onto another directory. It has nothing to do with a PATH command. I use a PATH command to establish paths to common directories that I need most of the time, like \MONEO\BATS, \MONEO\TOOLS and MONEO\QB45, so that at any time I can invoke batchfiles, utilities or the QB45 complier and linker from whatever directory I'm currently at. Get it?
*****
Ah, so u want to change the environment variables of the shell you are currently in. I have no idea how you could achieve it =P.
To change your present environment variables you should use ENVIRON$ (or something like this, I don't have QB at hand to check now).
way to go. I just checked out ENVIRON$() function and its exactly what Moneo needs.

heres a link =P
Moneo, let me undestand this.

1. Let's say you open a shell. For example using QB's "SHELL COMMAND.COM" or in the command line running "COMMAND".

2. Now you run a BAT file that changes the path.

3. Once the BAT has exited, the path is not changed?

Am I right?

Well, I've tried it. If I just open a DOS box and change the path from a BAT file it works. But if I type "COMMAND" to open a new shell it doesn't, for any reason.

I really can't dig a sollution.
Sorry for the useless post Tongue
Pages: 1 2 3 4 5