I have come across the need to compress some SQL backups as they are made. As such, I needed to create a script that will find the appropriate files, zip them & then delete the original file.
I found the following which seemed to help:
I had a completed script, calling the function below, which seemed to be working perfectly. Until, that is, I swapped the test .bak files with something a little bigger in size (from a few bytes to approx 6MB). Now I get the following error:
Error: Object required: 'shl.namespace(...)'
If I put a msgbox just before the do..loop, i can see the compression dialog and if I wait for this to finish before pressing ok, then no error.
As such, I need to find a different way to test that the compression is complete. This is where I have now come up against a brick wall.
Is anyone able to suggest an alternative method for checking that this has completed before letting the code move on?
For your information, both strSource & strTarget are provided as filenames with full paths. strTarget being the zip file.
Any help would be greatly appreciated.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'write zip file header
set file = fso.opentextfile(strTarget,ForWriting,true)
file.write "PK" & chr(5) & chr(6) & string(18,chr(0))
'copy source file to zip file
set shl = CreateObject("Shell.Application")
do until shl.namespace(strTarget).items.count = 1
set shl = nothing