I have a QBasic program that uses the SHELL command without any arguments/strings, therefore it starts a new instance of the "command.com" DOS prompt.
My questions is, does this SHELL command still work under Windows XP? If I compile my QBasic program and make an .EXE file from it, will it still work in XP even though it uses the SHELL command?
I know there is the "CMD.EXE" command under Windows XP, but will a DOS program still be able to use "Command.com" activated by the SHELL command?
My program is a non-graphical QBasic program, text mode only, Screen zero to be exact. I simply need to use the command prompt to rename a file, possibly copy it, and then use the TYPE | MORE command, and then return to my program.
I use a Windows ME computer and I don't have access to Windows XP. I'm curious if anybody knows whether QBasic programs with the SHELL command will cause any issues under Windows XP and newer versions.
Thank you... I hope somebody knows :-)
Does the SHELL command still work in XP?
Re: Does the SHELL command still work in XP?
shell ("command")
gives on XP :
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\DOCUME~1\USER\DESKTOP\FBC\FBIDE>
'========================================
Shell ("cmd") gives:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\USER\Desktop\fbc\FBIde>
'=====================================================
'=====================================================
And with QuickBasic :
shell("command"):
WARNING: THIS MICROSOFT PRODUCT HAS BEEN TESTED AND CERTIFIED
FOR USE ONLY WITH THE MS-DOS AND PC-DOS OPERATING SYSTEMS.
YOUR USE OF THIS PRODUCT WITH AN THER OPERATING SYSTEM MAY
VOID VALUABLE WARRANTY PROTECTION PROVIDED BY MICROSOFT ON
THIS PRODUCT.
Press any key to continue
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\BC7\BIN>
'======================================================
shell ("cmd"):
WARNING: THIS MICROSOFT PRODUCT HAS BEEN TESTED AND CERTIFIED
FOR USE ONLY WITH THE MS-DOS AND PC-DOS OPERATING SYSTEMS.
YOUR USE OF THIS PRODUCT WITH AN THER OPERATING SYSTEM MAY
VOID VALUABLE WARRANTY PROTECTION PROVIDED BY MICROSOFT ON
THIS PRODUCT.
Press any key to continue
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\BC7\BIN>exit
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\BC7\BIN>
gives on XP :
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\DOCUME~1\USER\DESKTOP\FBC\FBIDE>
'========================================
Shell ("cmd") gives:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\USER\Desktop\fbc\FBIde>
'=====================================================
'=====================================================
And with QuickBasic :
shell("command"):
WARNING: THIS MICROSOFT PRODUCT HAS BEEN TESTED AND CERTIFIED
FOR USE ONLY WITH THE MS-DOS AND PC-DOS OPERATING SYSTEMS.
YOUR USE OF THIS PRODUCT WITH AN THER OPERATING SYSTEM MAY
VOID VALUABLE WARRANTY PROTECTION PROVIDED BY MICROSOFT ON
THIS PRODUCT.
Press any key to continue
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\BC7\BIN>
'======================================================
shell ("cmd"):
WARNING: THIS MICROSOFT PRODUCT HAS BEEN TESTED AND CERTIFIED
FOR USE ONLY WITH THE MS-DOS AND PC-DOS OPERATING SYSTEMS.
YOUR USE OF THIS PRODUCT WITH AN THER OPERATING SYSTEM MAY
VOID VALUABLE WARRANTY PROTECTION PROVIDED BY MICROSOFT ON
THIS PRODUCT.
Press any key to continue
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\BC7\BIN>exit
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\BC7\BIN>
Re: Does the SHELL command still work in XP?
Thanks for the reply. I take it that SHELL will work under XP. Wasn't sure because I don't have an XP computer.
What about just plain SHELL, no arguments?
What if you did this:
CLS
SHELL
END
Will that work too?
What about just plain SHELL, no arguments?
What if you did this:
CLS
SHELL
END
Will that work too?
Re: Does the SHELL command still work in XP?
cls
shell
end
This does nothing
The program ends directly.
shell
end
This does nothing
The program ends directly.
-
- Site Admin
- Posts: 6237
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Does the SHELL command still work in XP?
Unlike QBASIC, FB does not open up an interactive command line when SHELL is called without parameters.
(/wiki/KeyPgShell)
(/wiki/KeyPgShell)
Re: Does the SHELL command still work in XP?
okay, what happens if...
I make a file called TEST.BAS and it contains only these 3 exact lines of code:
1 CLS
2 SHELL
3 END
^ The above code is compiled using FREEBASIC DOS Compiler and the argument "FBC -Lang qb test.bas"
What does TEST.EXE do when run in Windows XP?
Does it give either...
(1) Command prompt*
(2) Nothing at all, ends automatically without user being able to input commands
(3) Some weird XP garbage that I've never heard of**
*command prompt being the place where I can enter DOS commands like "REN", "DIR", "TYPE, "CD." And I can also return to my program by typing in "EXIT."
**please explain in simple layman's terms
Thank you all for replying. Sorry for this confusion :-(
I make a file called TEST.BAS and it contains only these 3 exact lines of code:
1 CLS
2 SHELL
3 END
^ The above code is compiled using FREEBASIC DOS Compiler and the argument "FBC -Lang qb test.bas"
What does TEST.EXE do when run in Windows XP?
Does it give either...
(1) Command prompt*
(2) Nothing at all, ends automatically without user being able to input commands
(3) Some weird XP garbage that I've never heard of**
*command prompt being the place where I can enter DOS commands like "REN", "DIR", "TYPE, "CD." And I can also return to my program by typing in "EXIT."
**please explain in simple layman's terms
Thank you all for replying. Sorry for this confusion :-(
Re: Does the SHELL command still work in XP?
counting_pine wrote:Unlike QBASIC, FB does not open up an interactive command line when SHELL is called without parameters.
(/wiki/KeyPgShell)
Remark about documentation:
KeyPgShell wrote:Return Value:
If command = "", or else the command could not be executed, -1 is returned. Otherwise, the command is executed and its exit code is returned.
On my PC (Windows XP), SHELL without parameters retuns 0.
Re: Does the SHELL command still work in XP?
I have an older freeBASICdos on drive C.
(version 20)
I make this test file called testshell.bas:
I click testshell.exe after I compile the above code via fbc testshell.bas
I get the command shell staying on the screen, I can enter commands (DIR .. etc. OK)
Whether I use #lang "qb" in the code or not.
Here is the console after clicking testshell.exe
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\FBDOS\FREEBA~1>
To free I just enter exit.
So, with fbdos and WinXP the command window stays until you want to exit.
(version 20)
I make this test file called testshell.bas:
Code: Select all
#lang "qb"
cls
shell
end
I click testshell.exe after I compile the above code via fbc testshell.bas
I get the command shell staying on the screen, I can enter commands (DIR .. etc. OK)
Whether I use #lang "qb" in the code or not.
Here is the console after clicking testshell.exe
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\FBDOS\FREEBA~1>
To free I just enter exit.
So, with fbdos and WinXP the command window stays until you want to exit.
Re: Does the SHELL command still work in XP?
Thanks, that's what I needed to know :-)
Thanks everyone for your answers.
Thanks everyone for your answers.
-
- Site Admin
- Posts: 6237
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Does the SHELL command still work in XP?
For SHELL, FreeBASIC calls the underlying runtime library's system() function. On DJGPP, it turns out this spawns an interactive shell when an empty string is passed:
http://www.delorie.com/djgpp/doc/libc/libc_802.html
To be honest, I think it would be nice if this behaviour could be replicated on other platforms, though I don't know if it would be easy to do reliably.
http://www.delorie.com/djgpp/doc/libc/libc_802.html
If cmd is an empty string, the command processor pointed to by `SHELL' or `COMSPEC' variables in the environment will be invoked interactively; type exit RET to return to the program which called system. (Note that some other DOS compilers treat a null pointer like an empty command line, contrary to ANSI C requirements.)
To be honest, I think it would be nice if this behaviour could be replicated on other platforms, though I don't know if it would be easy to do reliably.
Who is online
Users browsing this forum: No registered users and 5 guests