Does the SHELL command still work in XP?

DOS specific questions.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Does the SHELL command still work in XP?

Postby Aaronm82 » Oct 05, 2014 15:24

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 :-)
dodicat
Posts: 6534
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Does the SHELL command still work in XP?

Postby dodicat » Oct 05, 2014 19:16

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>
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: Does the SHELL command still work in XP?

Postby Aaronm82 » Oct 05, 2014 21:50

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?
dodicat
Posts: 6534
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Does the SHELL command still work in XP?

Postby dodicat » Oct 05, 2014 22:49

cls
shell
end

This does nothing
The program ends directly.
counting_pine
Site Admin
Posts: 6209
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Does the SHELL command still work in XP?

Postby counting_pine » Oct 06, 2014 0:21

Unlike QBASIC, FB does not open up an interactive command line when SHELL is called without parameters.
(/wiki/KeyPgShell)
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: Does the SHELL command still work in XP?

Postby Aaronm82 » Oct 06, 2014 2:10

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 :-(
fxm
Posts: 9696
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Does the SHELL command still work in XP?

Postby fxm » Oct 06, 2014 7:17

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.
dodicat
Posts: 6534
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Does the SHELL command still work in XP?

Postby dodicat » Oct 07, 2014 14:52

I have an older freeBASICdos on drive C.
(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.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: Does the SHELL command still work in XP?

Postby Aaronm82 » Oct 07, 2014 16:43

Thanks, that's what I needed to know :-)

Thanks everyone for your answers.
counting_pine
Site Admin
Posts: 6209
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Does the SHELL command still work in XP?

Postby counting_pine » Oct 07, 2014 16:54

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

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 3 guests