bas7advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SHELL Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The SHELL statement suspends execution of a BASIC program, runs a .COM,
.EXE, .BAT or .CMD program, or a DOS or OS/2 command, and resumes
execution of the BASIC program at the statement following the SHELL
statement.
 
SHELL [commandstring$]
    ■ The argument commandstring$ is a string expression that contains a
      valid DOS or OS/2 command or the name of a .COM, .EXE, .BAT, or .CMD
      program and any program arguments.
 
Programming With OS/2 Protected Mode
    ■ If you are using OS/2, make sure that the SET COMSPEC configuration
      command in your CONFIG.SYS file specifies the path for the CMD.EXE
      file. If the path for CMD.EXE is not set, you will get an error
      message when SHELL searches for the CMD.EXE file.
 
Usage Notes
    ■ Any .COM file, .EXE file, .BAT program, .CMD program, DOS command,
      or OS/2 command that runs under the SHELL statement is called a
      "child process." Child processes are executed by the SHELL
      statement, which loads and runs a copy of COMMAND.COM (for DOS) or
      CMD.EXE (for OS/2) with the /C option.
    ■ The /C option allows any parameters in commandstring$ to be passed
      to the child process. It also allows redirection of standard input
      and output, and execution of built-in commands such as DIR and PATH.
    ■ The program name in commandstring$ can have any extension you
      wish. If no extension is supplied, COMMAND.COM (for DOS) or CMD.EXE
      (for OS/2) looks for a .COM file, then an .EXE file, and finally,
      a .BAT file (for DOS) or a .CMD file (for OS/2). If COMMAND.COM
      or CMD.EXE is not found, SHELL issues the error message,
      "File not found." BASIC does not generate an error if COMMAND.COM or
      CMD.EXE cannot find the file specified in commandstring$, but
      the operating system will generate an error message.
    ■ COMMAND.COM or CMD.EXE treat as program parameters any text
      separated from the program name by at least one blank.
    ■ BASIC remains in memory while the child process is running. When
      the child process finishes, BASIC continues.
    ■ SHELL with no commandstring$ gives you a new shell (COMMAND.COM for
      DOS or CMD.EXE for OS/2). You then can enter operating-system
      commands at the prompt.  Use the EXIT command to return to BASIC.