Waiting for a batch file to finish
Folks
I'm using a bit of code to create a batch file, that copies the file structure into a text file:
'create a batch file
Open strDrive & "q.bat" For Output As #intFreeFile
Print #intFreeFile, "xcopy " & strDrive & "*.* d:\ /e/c/l/h/r/y > " & strDrive & "myFiles.txt"
Close #intFreeFile
I then run the batch file:
dblRetVal = Shell(strDrive & "q.bat", vbHide)
Once the file has completed I want to "kill" the batch file. How can I do this (if its possible of course)?
I thought that if I try to open the file that its writing to before its complete it would generate an error. So if I could write a loop of some sort that tries to access the file say, every 5 seconds, if its not finished, it will error, so re-start the timer, whereas when I can open the file, it must mean the batch file is completed...
You can see I'm a newbie can't you... :-) does this make sense, is it possible, or is there any easier way? I'm not specifically looking for a bit of code as an answer, just a point in the right direction, otherwise I'll never learn.
Cheers
Regards
Russ (Programing on L plates..!)
__________________
Regards
Russ (Programing on L plates..!)
|