在VBScript中压缩文件时等待

时间:2019-06-13 17:19:02

标签: windows vbscript filesystems

我有一段压缩两个文件的代码:

 'Deleting ZIP file and creating new one
  Set FSO = CreateObject("Scripting.FileSystemObject")
    if fso.fileExists("C:\Test.zip") then
    fso.DeleteFile("C:\Test.zip")
    end if

  ' creating zip file
  set file = FSO.CreateTextFile("Test.zip")
  file.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
  file.close

  'Coping files to ZIP file 
  Set objShell = CreateObject("shell.Application")

  Set objFolderZIP = objShell.NameSpace("C:\Test.zip")

  cnt = objFolderZIP.Items.Count + 1
  objFolderZIP.CopyHere("C:\Zip01.xls")
  While objFolderZIP.Items.Count < cnt
      WScript.Sleep 100
  Wend

  cnt = objFolderZIP.Items.Count + 1
  objFolderZIP.CopyHere("C:\Zip02.xls")
  While objFolderZIP.Items.Count < cnt
      WScript.Sleep 100
  wend


MsgBox "Files ZIP-ed"

两个文件均被复制到.zip文件夹,没有问题。问题是,如果文件很大,则在仍在压缩文件的同时弹出“文件ZIP-ed”消息框,其中有用于压缩的加载栏。我希望在文件完全压缩(复制到.zip文件)后出现弹出消息。

0 个答案:

没有答案