<-- Previous || Up || Next -->

Shell Wait Function
Windows API Class

Public Function ShellWait( _
      ByVal vCommand As String _
    , Optional ByVal vFocus As Variant _
    , Optional ByVal vSendKeys As Variant _
    , Optional ByVal vAllowDoEvents As Variant _
    ) As Long

Executes a Windows or DOS program and wait for it to complete.
Its window gets the specified focus.
Function optionally sends keystrokes to the program.
Function returns either 0 (zero) upon success or the number of the error encountered.

    ShellWait("CharMap.Exe", vbNormalNoFocus) = 0
    ShellWait("NotePad.Exe NewFile.Txt") = 0
See also:
    ShellNoWait Function
    vbNormalFocus Property, et. al.
    PrefixSendKeysMetaCharacters Function
    Shell Function (Visual Basic)
    SendKeys Statement (Visual Basic)
    DoEvents Statement (Visual Basic)
vCommand: The Windows or DOS command that is to be executed. This command line must include a program name, and it can optionally include one or more command line arguments.

vFocus: The focus given to program's window. Should be one of the Visual Basic focus Constants like vbNormalFocus, vbNormalNoFocus, etc. vFocus defaults to vbNormalFocus if it is missing or Null or cannot be fixed-up to a number.

vSendKeys: String that will be sent to the program as keystrokes after it is started. vSendKeys defaults to an empty string (no keystrokes will be sent) if it is missing or Null or cannot be fixed-up to a string.
Warning: vSendKeys is ignored if vFocus is vbHide, vbMinimizedNoFocus, or vbNormalNoFocus.

vAllowDoEvents: True if the use of DoEvents is permitted within this function. False if DoEvents is not allowed. Read the warnings below carefully.
Warning: Uses DoEvents so that this function can detect the end of 16-bit Windows Programs within the 32-bit version of Entisoft Tools. This may possibly cause problems when this function is used within the 32-bit In-process version of Entisoft Tools, since there are restrictions on using DoEvents within In-process servers--see the Visual Basic documentation.
Note: When executing 16-bit Windows applications from the 32-bit version of Entisoft Tools, you must set vAllowDoEvents to True (its default) otherwise it cannot detect the end of the program. Unfortunately, the DoEvents statements are not recommended by Microsoft for use within in-process OLE Automation Servers (such as Entisoft Tools). See the Visual Basic 4.0 documentation and help file for more information.
v1.3 Change: Removed 16-bit support from this function.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.