Results 1 to 2 of 2

Thread: How tell if shelled app is finished

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    45
    I shell a .bat file which runs a DOS app. The DOS app's output is redirected to a file. I need to read that file when the DOS app is finished.

    I thought that I could tell when the DOS app finished with:

    DO WHILE Dir(redirectedfile) = ""
    Loop

    assuming that Dir would return an empty string until the redirectedfile is completed and closed by DOS. However, it apparently "finds" the file as soon as the DOS app starts.

    How can I determine that the DOS app is done?

    TIA,

    Don Goyette

  2. #2
    Guest
    Code:
    Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As
    Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As
    Long, lpExitCode As Long) As Long
    Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
    Const STILL_ACTIVE = &H103
    Const PROCESS_QUERY_INFORMATION = &H400
    
    'Code:
    Sub Shell32Bit(ByVal JobToDo As String)
    
             Dim hProcess As Long
             Dim RetVal As Long
             'The next line launches JobToDo as icon,
    
             'captures process ID
             hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo,1))
    
             Do
    
                 'Get the status of the process
                 GetExitCodeProcess hProcess, RetVal
    
                 'Sleep command recommended as well as DoEvents
                 DoEvents: Sleep 100
    
             'Loop while the process is active
             Loop While RetVal = STILL_ACTIVE
    
    
    End Sub
    I was searching my computer for something on this and this code came up. I am not exactly sure how to use it, but it says that it Monitors a DOS Window.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width