Knowing when Shell command is complete
Posted on 2007-08-12
I am executing a zip and unzip using a shell command in my VB6.0 app. The command looks like
" Shell (zipIT & target & backupString)"
The issue is that I can't proceed with my next operation until the unzip (or zip) is complete.
How can I know that the unzip is complete so that I can proceed with my next statement?
I have a rather bogus idea that seems like it might work assuming shell comands are executed in order.
The VB code sequence would be :
1. Execute shell command to create "marker' (Marker.txt) file on the disk. The name or contents of the file isn't improtant but I would have to know its name in subsequent steps.
2. Shell (zipIT & target & backupString)"
3. Execute a shell command to delete the "marker" (Marker.txt) file.
4. VB code that checks for the existense of "Marker.txt" in a timing lopp of approximately 5 seconds.
Dim delaycnt As Integer
Dim zipFound As Boolean
zipFound = False
For delaycnt = 1 To 20 ' total of 5 seconds
If Dir("Marker.txt") <> "" Then
else ' it's gone
zipFound = false
When the file dissapears I drop out of the loop and can continue with my next operation because I know that all three shell commands are complete.
Will this work? There seeems like there must be a more direct way.
what shell command could I execute to crete, and then delete the marker.txt file?