ID Number: Q80439
1.00
WINDOWS
Summary:
The Shell function in Microsoft Visual Basic for Windows allows you to
run applications for both Windows and MS-DOS. You may find that if you
attempt to pass filename arguments to a program invoked with the Shell
function, the shelled program might not find the specified file (even
though you specify a complete path and filename).
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Many programs are written to accept filenames as command-line
arguments. An example of this is the MS-DOS command TYPE. To list the
contents of a text file you can use the TYPE command at the MS-DOS
command prompt as follows:
type autoexec.bat
This command will cause the contents of the AUTOEXEC.BAT file to be
displayed on the screen.
Similarly, you can pass command-line arguments to an application
written for Windows by modifying the Command Line box in the Program
Item Properties dialog box, which is accessed by choosing Properties
from the File menu in the Windows Program Manager.
From Visual Basic, you can specify command-line arguments for a
shelled program by placing the command-line arguments after the
executable filename. For example:
x% = Shell("C:\WINDOWS\NOTEPAD.EXE C:\AUTOEXEC.BAT",1)
Some programs seem to have trouble using filenames passed as
command-line arguments to the Shell function. The program may be
unable to find the file, or the program may produce an unexpected
error. This behavior is dependent on the program being shelled to, and
is not a problem with Visual Basic.
To work around this problem, try using the ChDir command to change to
the directory containing the program being shelled to. For example:
ChDir "C:\WINDOWS"
x% = Shell("NOTEPAD.EXE C:\AUTOEXEC.BAT",1)
This method sometimes allows the shelled program to proceed without
error.
Additional reference words: 1.00