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