Why wait the end of a Shell process ? 
Author Message
 Why wait the end of a Shell process ?

Hello,

I use the commande Shell for calling the program FTP.EXE.

But this operation is asyncronous

Why can I wait the end of the shell command before continue my fonction
?

thanks you !



Sun, 24 Nov 2002 03:00:00 GMT  
 Why wait the end of a Shell process ?
Hope this helps!
--------------------------------------------------------

Option Compare Database

Const PROCESS_QUERY_INFORMATION = &H400
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFFFFFF

Const STILL_ACTIVE = &H103&

Const ERR_FILE_NOT_FOUND = 53

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

' Run an application, waiting for its completion
' before returning to the caller.

   Dim hInstance As Long
   Dim hProcess As Long
   Dim lngRetval As Long
   Dim lngExitCode As Long

   On Error GoTo ahtRunAppWait_Err

   ' Start up the application.
   hInstance = Shell(strCommand, intMode)
   hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or SYNCHRONIZE, _
      True, hInstance)
   Do
      ' Attempt to retrieve the exit code, which will
      ' just not exist until the application has quit.
      lngRetval = GetExitCodeProcess(hProcess, lngExitCode)
      DoEvents
   Loop Until lngExitCode <> STILL_ACTIVE

ahtRunAppWait_Exit:
   Exit Sub

ahtRunAppWait_Err:
   Select Case Err.Number
      Case ERR_FILE_NOT_FOUND
         MsgBox "Unable to find '" & strCommand & "'"
      Case Else
         MsgBox Err.Description
   End Select
   Resume ahtRunAppWait_Exit
End Sub


Quote:
> Hello,

> I use the commande Shell for calling the program FTP.EXE.

> But this operation is asyncronous

> Why can I wait the end of the shell command before continue my fonction
> ?

> thanks you !



Sun, 24 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help: Wait for shelled process to end

2. Wait for the end of a process

3. HOWTO start a process and wait for its end

4. Wait for the end of a process

5. Wait for Process to end?

6. ShelllExecute then wait for process to end

7. Forcing Access to wait the end of an application started by SHELL

8. how to wait for shell to end

9. executing via Shell and waiting for the end

10. SHELL and wait until the end of the program

11. Waiting for shell to end to continue

12. Waiting until DOS-shell ends...

 

 
Powered by phpBB® Forum Software