The information in this article applies to:
SYMPTOMSWhen you execute the Shell command to run a batch (.BAT) file, no error message is generated if the batch file specified does not exist. MORE INFORMATION
The following is from the Help topic "Shell":
The Visual Basic Shell command runs an executable program. If the Shell() function successfully executes the named program, it returns the instance handle of the started program. If the Shell() function can't start the named program, an error occurs. However, if you use Shell to run a batch file that does not exist, a modal dialog box inclusing the following text is generated: Cannot find file. In this case, Visual Basic continues to run, no error message is generated, and the return value from Shell() has a legitimate Windows instance handle. CAUSE
This is by design and is the same behavior you see when using the Windows
API WinExec. "Shelling" to a batch program generates a handle to the
command processor, which runs the batch program. This handle is returned to
Visual Basic. When the command processor determines that there is no such
batch file, it is a process independent from Visual Basic and the error is
therefore not reported to Visual Basic.
Steps to Reproduce the Problem
WorkaroundReplace the code from the above example with the following code:
Additional query words: 2.00 3.00
Keywords : |
Last Reviewed: June 25, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |