Does anyone know of a method to determine when a file copy completes in VBScript? I'm using the following to copy:
set sa = CreateObject("Shell.Application")
set zip = sa.NameSpace(saveFile)
set Fol = sa.NameSpace(folderToZip)
zip.copyHere (Fol.items)
Do Until zip.Items.Count = Fol.Items.Count
WScript.Sleep 300
Loop
When the loop finishes your copy is finished.
But if you only want to copy and not zip, FSO or WMI is better.
If you are zipping and want them in a file you have to create the zip-file yourself, with the right header first. Else you only get compressed files/folders IIRC. Something like this:
Set FSO = CreateObject( "Scripting.FileSystemObject" )
Set File = FSO.OpenTextFile( saveFile, 2, True )
File.Write "PK" & Chr(5) & Chr(6) & String( 18, Chr(0) )
File.Close
Set File = Nothing
Set FSO = Nothing
The 2 in OpenTextFile is ForWriting.
You may have better luck using the Copy method on a FileSystemObject
. I've used it for copying, and it's a blocking call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With