How to determine when copy finishes in VBScript?
copy, filesystems, vbscript
Solution
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.
Problem
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) ```