Microsoft KB Archive/45908

= QuickBasic Cannot RUN or CHAIN to Batch Files; Use SHELL =

Article ID: 45908

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft GW-BASIC 3.2
 * Microsoft GW-BASIC 3.22
 * Microsoft GW-BASIC 3.23
 * Microsoft QuickBasic 1.0
 * Microsoft QuickBasic 1.01
 * Microsoft QuickBasic 1.02
 * Microsoft QuickBasic 2.0
 * Microsoft QuickBasic 2.01
 * Microsoft QuickBasic 3.0
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q45908



SUMMARY
Batch (.BAT) files can be executed only from a Basic program SHELL statement. The RUN and CHAIN statement cannot be used to execute a batch file.

This information applies to the following Basic products:


 * 1) Microsoft GW-Basic Versions 3.20, 3.22, and 3.23
 * 2) QuickBasic Versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50
 * 3) Microsoft Basic Compiler Versions 6.00, and 6.00b for MS-DOS and MS OS/2.
 * 4) Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.



MORE INFORMATION
The SHELL statement can be used to execute a .COM, .EXE, or .BAT file, or almost any MS-DOS command, and then return to the original Basic program. However, the SHELL statement cannot pass any information or variables to the program or statement it is executing.

The statement or program being executed from the SHELL statement is being executed as a &quot;child&quot; process of Basic. The Basic program is exited (but remains in memory), the command string is executed, and then control is returned to the Basic program. Two methods can be used to pass information down to a batch file:


 * 1) Write the information to a file and have the batch file access the file for the necessary information.
 * 2) Set a special environment variable with ENVIRON that can be read by the batch file.

The RUN and CHAIN statements expect to RUN or CHAIN to a program that has an extension of .BAS or .EXE, depending on whether the program is being executed within the QB.EXE or QBX.EXE environment or as a compiled application.

For more information, consult the Basic language reference manual included with your Basic package.

Additional query words: QuickBas BasicCom

Keywords: KB45908

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.