Creating a Zip then copying folders to it

后端 未结 2 574
我在风中等你
我在风中等你 2021-01-21 16:11

I\'m trying to create a zip file, then copy three folders into it. I get the error on line 33 char 1, error state object required, I have searched and googled but just can\'t se

2条回答
  •  伪装坚强ぢ
    2021-01-21 16:53

    WinZip has a Command Line Interface. You might have to download and install it depending on your version: http://www.winzip.com/prodpagecl.htm

    The below is a test script that works for WinZip version 9.0 if it helps.

    Const WinZip = "C:\Program Files\WinZip9.0\wzzip.exe"  'WinZip Version 9.0
    
    BasePath = "C:\Path\To\Folders\"
    
    strZipFilePath = BasePath & "Test.zip"
    strArchiveMe = BasePath & "Folder_A"
    
    Set objShell = CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If Not objFSO.FileExists(WinZip) Then
        MsgBox "WinZip (wzzip.exe) Does Not Exist"
        WScript.Quit
    End If
    
    '''// For Below Command - Change "-a" TO "-mu" To Auto Delete The file After Zip Is Created
    '''// For Below Command - Change "-yb" TO "-ybc" To Answer YES To all Promps and not Terminate Operation
    strcommand = Chr(34) & WinZip & Chr(34) & " -a -yb " & Chr(34) & strZipFilePath & Chr(34) & " " & Chr(34) & strArchiveMe & Chr(34)
    objShell.Run strcommand, 1, True
    

    The command format is:

    winzip [action] [options] [Zip Path] [Path to file/folder to zip]
    

提交回复
热议问题