End a shell process ??? 
Author Message
 End a shell process ???

I can i know if a shell process has ended..
I use the SHELL function to launch pkunzip, but i don't know if my files
are
unziped.
does anyone know how to get a proces status (ended,working.??.).
thanx



Sun, 30 Jan 2000 03:00:00 GMT  
 End a shell process ???

I had a problem with the WaitFormSingleObject API falling through before my
MSDOS prompt completed it's job, so I wrote this little jobber...
  I hate to recommend anyone do this, but here's a sub almost guaranteed to
work.
It creates a temp file, ending in ".sync", Then builds a DOS batch file to
run
the program you want.  The batch file deletes the ".sync" file after your
program
terminates, which lets the do...loop continue, and the routine exits.

PS: Check out pg460 of {*filter*} VB, "When all else fails, hit it with a
hammer" if
    you need justification to include this 'code.'

aside from the shortcomings you may notice immediatley, note that:

  1) If you are executing a batch file (e.g. Setup.BAT), you MUST
     send sProgName as "CALL Setup.BAT"

  1a) The win95 DOS command "CALL" was never modified for filenames
containing spaces,
      (you can't even use quotes), so if you need to "Call \Program
Files\Temp\Setup.BAT",
      you should pass, "Call \Progra~1\Temp\Setup.BAT"

  2) If you're not in VB5, make the Optional param a Variant, and trap with
IsMissing in the
     body.
....

Private Sub ShellAndWait(sProgName As String, Optional awsWindowSettings As
VbAppWinStyle = vbMinimizedFocus)
  Dim hBatFile As Integer
  Dim hSyncFile As Integer
  Dim sTempName As String
  Dim sTempBatch As String

  sTempName = "\" & App.EXEName & "TEMP" & Format$(Time, "hhmmss") &
".sync"
  sTempBatch = "\" & App.EXEName & "TEMP" & Format$(Time, "hhmmss") &
".bat"
  hSyncFile = FreeFile
  Open sTempName For Binary Access Write As hSyncFile
  Put #hSyncFile, , "WAITING FOR " & sProgName
  Close hSyncFile

  hBatFile = FreeFile
  Open sTempBatch For Binary Access Write As hBatFile

  Put #hBatFile, , sProgName & vbCrLf
  Put #hBatFile, , "del " & sTempName & vbCrLf
  Close hBatFile

  Shell sTempBatch, awsWindowSettings
  Do While Dir(sTempName) <> ""
    DoEvents
  Loop

  Kill sTempBatch

End Sub



Quote:
> I can i know if a shell process has ended..
> I use the SHELL function to launch pkunzip, but i don't know if my files
> are
> unziped.
> does anyone know how to get a proces status (ended,working.??.).
> thanx



Tue, 01 Feb 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Why wait the end of a Shell process ?

2. How to determe when a SHELLed process ends.

3. Check if a Shell Process Ends

4. How a 32-Bit App Can Determine When a Shelled Process Ends, Article ID: Q129796

5. Help with Determining Shell Process Ends

6. Shell launch / Process End

7. How a 32-Bit App Can Determine When a Shelled Process Ends

8. Determine When shelled process end

9. Determining when a shelled process ends

10. Shelled Process does not end

11. How a 32-Bit APP can Determine When a Shelled Process Ends - Q129796

12. Help: Wait for shelled process to end

 

 
Powered by phpBB® Forum Software