Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PATH doesn't work within a DOS SHELL --- Why?
#11
Nathan, when he invokes the batch file from inside QB, it opens up a new shell for the batch file. Thus whatever changes he makes to the environment variables through the batch file affects only its own environment and not the .exes =(.

I have posted a link to the Environ$ command which should solve his problem.
Reply
#12
No, I'm running the batchfile from the DOS commandline, the DOS commandline of the DOS Shell that I'm in. I'm not using the QB environment at all.

I think Nathan has discovered something, that is, there seems to be different types of DOS Shells.

I'll look into the ENVIRON stuff though I don't think this has much to do with it.
*****
Reply
#13
Path only works for the current DOS shell, as soon as you open a DOS program in a windows shell, it starts a new shell for that program.

Shell1
BAT -> Shell2 (suspend Shell1)
Run BAT using Shell2
BAT -> end (Reactivate Shell1)
Shell1

A BAT file is a new command prompt in itself, you could try:
BAT1:
SET PATH %PATH, "My path"
BAT2

And then run BAT1 whenever you want to run BAT2, not sure if this work though.
Reply
#14
Code:
'When a shell is opened it gets a copy of it's parent's environment
'
'this changes the path in the shell's environment
'
OPEN "chpath.bat" FOR OUTPUT AS 1
PRINT #1, "@echo off"
PRINT #1, "path=a:\"
PRINT #1, "echo path has changed"
PRINT #1, "path"
PRINT #1, "pause"
CLOSE #1
SHELL "chpath.bat"
'
'When a shell is closed it's copy of the environment is deleted
'so in a new shell path is back to the original...
'
OPEN "test.bat" FOR OUTPUT AS 1
PRINT #1, "@echo off"
PRINT #1, "echo and path is..."
PRINT #1, "path"
PRINT #1, "pause"
CLOSE #1
SHELL "test.bat"

'
'this changes path in QB's environment
'
'NOTE: W2000's (probably also XP's) environment is a huge monster
'of 30 lines and QB can't cope with it :ENVIRON gives an out of memory
'error.....It should work in W9x or DOS
'
ENVIRON "path=a:\"
'
'The change in the path is transmitted to the shell
'
SHELL "test.bat"
Antoni
Reply
#15
ANTONI. I know you're trying to help, but your changing the circumstances under which I'm having the problem.

I'll repeat the scenario:

* I'm in a DOS Shell. I get into this shell from a utility program which has an option "go to DOS". I can get the same DOS Shell if I run the old BASIC interpreter and issue a SHELL command with no parameter.

NOTE: I execute the utility program or the BASIC interpreter by selecting and running it from Windows' "My Computer".

The DOS Shell has the following opening message:
<< Use EXIT to return >> Microsoft® Windows DOSDn
©Copyright Microsoft Corp 1990-2001

* The above puts me on the DOS comand-line. Most everything seems to work when launched from this 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 this command-line while being in the same DOS Shell, IT IGNORES THIS PATH COMMAND --- WHY?

* The same thing happen in Windows 2000 or Windows XP.

NOTE: If I exit to DOS from Windows using the Run CMD, it puts me in a different kind of DOS Shell. If I repeat the above scenario and run the utility program or BASIC to provoke a DOS Shell, then this nested shell won't let me run hardly anything from the comand-line. But, this is not my main concern.
*****
Reply
#16
See my previus post, it works on w98
Reply
#17
Ok, I think I understood what your problem is. The DOS shell accepts the PATH statement if you just type it on the command line of your current DOS Shell. But it doesnt work if you make a batch file to do it for you.

Could you please post the batch file?
Reply
#18
As you can see if you run my code, a batch file can change your path while you're in a shell open from a QB program.

Probably the utility you use is filtering the commands you issue and does'nt allow path to work...
Antoni
Reply
#19
Frankly, moneo the explanation you've posted is quite confusing =(.
Reply
#20
And I think it is not.

Moneo, I have recreated your steps and have met the same thing. But I need to know something to get to a conclusion:

¿What's your exact PATH line in the BAT file?
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)