代码之家  ›  专栏  ›  技术社区  ›  aviv

如何使用Windows XP的内部选项在VBScript中解压缩文件

  •  15
  • aviv  · 技术社区  · 17 年前

    Set objShell = CreateObject("Shell.Application")
    
    Set SrcFldr = objShell.NameSpace(fileName)
    Set DestFldr = objShell.NameSpace(appDir)
    DestFldr.CopyHere(SrcFldr) 
    

    1 回复  |  直到 16 年前
        1
  •  34
  •   Joshua Taylor    9 年前

    只需将ZipFile=zip文件的位置,并将ExtractTo=设置为zip文件应提取到的位置。

    'The location of the zip file.
    ZipFile="C:\Test.Zip"
    'The folder the contents should be extracted to.
    ExtractTo="C:\Test\"
    
    'If the extraction location does not exist create it.
    Set fso = CreateObject("Scripting.FileSystemObject")
    If NOT fso.FolderExists(ExtractTo) Then
       fso.CreateFolder(ExtractTo)
    End If
    
    'Extract the contants of the zip file.
    set objShell = CreateObject("Shell.Application")
    set FilesInZip=objShell.NameSpace(ZipFile).items
    objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
    Set fso = Nothing
    Set objShell = Nothing