Qbasicnews.com

Full Version: SHELL in XP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have this program that runs perfectly in win 9x, but this line screws up in XP:

[syntax="qbasic"]SHELL "dir c:\*.mp3 /s /b >> c:\out.txt"[/syntax]

...And returns "Path not Found". I don't usually program for XP, so I have no idea what's wrong - all the switches are valid, and the same line works when typed directly into the command prompt.

What gives?
[syntax="qbasic"]SHELL "CMD dir c:\*.mp3 /s /b >> c:\out.txt"[/syntax]
Ah.


Well that makes things easy. Thanks, man. 8)


* mutters something about XP * :barf:
Btw, you only need one >, redirect symbol.

Your code now says:
Redirect to, redirect to c:\out.txt

It's enough to say: Redirect to c:\out.txt, don't you think? =)




To make a program that work on all computers, you could:

Pseudo code
Code:
create a bat file, saying: dir c:\*.mp3 /s /b > c:\out.txt

SHELL "The bat file"

Remove the bat file

That way it doesent matter if it's XP 9x or whatever, as long as it support's standard BAT files, which, I THINK, all versions of windows do.
Quote:Btw, you only need one >, redirect symbol.

Your code now says:
Redirect to, redirect to c:\out.txt

It's enough to say: Redirect to c:\out.txt, don't you think? =)`
NO. one > means redirect and write on the file.
Two >> means redirect and append to the file.
*****
:oops:


Didn't know that Moneo, thanks for the correction.
Thanks for the tips. And Zire: I didn't know the difference between >> and >, either. Tongue
Some guys that write batchfiles always use >> in order to make sure not to clear the existing file.
If the file does not exist the >> will do the same thing as >.
If the file exists, > will replace the file with the new contents.
If the file exists, >> will just append the new contents to the existing file.
*****
Quote:[syntax="qbasic"]SHELL "CMD dir c:\*.mp3 /s /b >> c:\out.txt"[/syntax]
BTW, inserting CMD into the SHELL command string may work in QBasic, but it won't work in QuickBasic 4.5, which of course is compiled. As a matter of fact, I suspect that although it may work in QBasic when you're running interpreted, I really doubt if it will work in QBasic compiled. I don't have QBasic, so check this out for me and let me know.
*****
CMD will open another DOS session in Windows NT/2K/XP, both from QBasic and QB, compiled and uncompiled. CMD is the command line interpreter which substitutes the "COMMAND.COM" monolith from MSDOS/Windows 9X/ME.
Pages: 1 2