Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = -1&
' Start the indicated program and wait for it
' to finish, hiding while we wait.
Public Function ShellAndWait(ByVal program_name As String, ByVal window_style As Long) As Boolean
Dim process_id As Long
Dim process_handle As Long
' Start the program.
On Error GoTo ShellError
process_id = Shell(program_name, window_style)
On Error GoTo 0
DoEvents
' Wait for the program to finish.
' Get the process handle.
process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
End If
ShellAndWait = True
Exit Function
ShellError:
ShellAndWait = False
MsgBox "Error starting task " & _
vbCrLf & _
Err.Description, vbOKOnly Or vbExclamation, _
"Error"
End Function
Option Explicit
Sub EndIfFileExists()
If Trim(Command) = "" Then End
If Dir$(Command) <> "" Then End
End Sub
Private Sub Form_Load()
Me.Caption = "Waiting for file " & Command
lblFileName.Caption = Command
EndIfFileExists
End Sub
Private Sub Timer1_Timer()
EndIfFileExists
End Sub
If Not ShellAndWait("ShellAndWait.exe " & FileName, vbMinimizedFocus) Then
'error logic
else
'process file
end if
Is that equivalent to my ShellAndWait command? If so, that is certainly a simpler way to go. Any ideas on how to wait until a file exists without writing your own custome command like I have done?rc = CreateObject("WScript.Shell").Run yourCommandHere, , True