Qbasicnews.com
February 26, 2020, 01:10:00 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4
  Print  
Author Topic: PATH doesn't work within a DOS SHELL --- Why?  (Read 9595 times)
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #30 on: February 17, 2004, 01:24:19 AM »

Quote from: "Moneo"
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.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
xhantt
Member
*
Posts: 90



« Reply #31 on: February 17, 2004, 12:08:55 PM »

That is really mysterious problem. What OS are you running? Perhaps this is a bug in the DOS Shell of such OS?
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #32 on: February 17, 2004, 04:09:09 PM »

Quote from: "Moneo"
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.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #33 on: February 18, 2004, 12:03:57 AM »

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.
*****
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #34 on: February 18, 2004, 11:09:13 AM »

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.
Logged

Antoni
Jonathan Simpson
Forum Regular
**
Posts: 140



« Reply #35 on: February 18, 2004, 11:56:19 AM »

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
Logged

onathan Simpson
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #36 on: February 18, 2004, 01:12:57 PM »

Antoni:
Yeah, or else just change the starting environment for all DOS Boxes by editing autoexec.bat (or config.sys?)
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #37 on: February 18, 2004, 01:25:43 PM »

Edited:
I suppose Moneo has more than one DOS PROGRAM in his PC so changing config.nt and autoexec.nt is not the solution...
Logged

Antoni
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #38 on: February 18, 2004, 01:31:19 PM »

more than one DOS?
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #39 on: February 20, 2004, 01:03:57 AM »

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. Cheesy
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #40 on: February 21, 2004, 12:11:48 AM »

Quote from: "xhantt"
That is really mysterious problem. What OS are you running? Perhaps this is a bug in the DOS Shell of such OS?

No, the same problem occurs in Windows XP and 2000 on 2 different PCs. Plus it also occurs on Nathan's machine.
*****
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #41 on: February 21, 2004, 07:29:30 AM »

Not a bug, it is a documented "feature" . See my previous post and Windows help about  implicit ENDLOCAL.

Batch in W2000 and XP works differently  than in DOS- W9x. It is much more powerful. Spanish readers can check the Batch tricks at my site. It's about all the strange things you needed to do in DOS-W9x batch to get the work done. ALL of that is now obsolete...

http://www.geocities.com/antonigual/batchtips.html
Logged

Antoni
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #42 on: February 22, 2004, 05:25:04 AM »

Quote from: "Antoni Gual"
Edited:
I suppose Moneo has more than one DOS PROGRAM in his PC so changing config.nt and autoexec.nt is not the solution...


I still dont understand why wont that work? I tried editing the autoexec.bat on my system and it worked. Infact now i remember that a while ago when i installed allegro for DJGPP as well as while installing it for Mingw32 I had edited my autoexec.bat to set the environment variables.
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #43 on: February 22, 2004, 10:36:59 AM »

He means that he needs that path just for that application, so changing the startup files won't work for him.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Moneo
Na_th_an
*****
Posts: 1971


« Reply #44 on: February 22, 2004, 09:01:49 PM »

Quote from: "Antoni Gual"
Not a bug, it is a documented "feature" . See my previous post and Windows help about  implicit ENDLOCAL.

Batch in W2000 and XP works differently  than in DOS- W9x. It is much more powerful. Spanish readers can check the Batch tricks at my site. It's about all the strange things you needed to do in DOS-W9x batch to get the work done. ALL of that is now obsolete...

http://www.geocities.com/antonigual/batchtips.html

You're right, Antoni, things have changed in the batchfile rules in Win2000 and WinXP.
For example, some of my QuickBasic programs generate and execute batchfiles. In order to delete these batchfiles when they're finished, I put a delete command to the batchfile name (DEL BATNAME) at the end of the batchfile but without a CRLF at the end of the record. It still works in Win2000 and WinXP, but it also displays an error message saying "The batch file cannot be found" on the screen which is very annoying especially for utility programs which I give to friends.

I haven't noticed any other differences, yet.
*****
Logged
Pages: 1 2 [3] 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!