none
How to add files into SecureZip compressor tool and encrypt with password RRS feed

  • Question


  • Hi

    I am trying to add files into SecureZip(pkware) tool through VB using shell command. example below

    --

    Sub Zip_Test1()

    Dim source As String, Mstr As String, target As String, password As String
    Dim file As Variant

    Application.DisplayAlerts = False
    Mstr = "C:\Users\Desktop\Test"

    For Each file In CreateObject("Scripting.FileSystemObject").GetFolder(Mstr).Files
    source = Chr$(34) & "C:\Users\Desktop\Test\" & file.Name & Chr$(34)

    target = "C:\Users\Desktop\Zipped\"   
    password = Chr$(34) & "Abcd1234" & Chr$(34)
    Shell ("C:\Program Files\PKWARE\PKZIPW\pkzipw.exe -add -pass=" & password & " " & target & " " & source)

    Exit Sub 'Exit for testing
    Next
    Application.DisplayAlerts = True
    End Sub

    --

    But I am getting error while adding files to archive. Error  Message - 

    "archive being opened but can not be found by secureZip".

    or

    "Invalid or unknown file format"

    I am only limited to use SecureZip tool so I cannot use any other compression tools.

    Please suggest me any approach to add file using vb and Securezip.


    • Edited by Croft12329 Wednesday, January 2, 2019 10:08 PM
    Wednesday, January 2, 2019 10:05 PM

All replies

  • I suggest you change program a little and test command in command prompt.  Once you have that working try it in VBA.  I added quotes around program exe since it has space.

    Sub Zip_Test1()
    
      Dim source As String, Mstr As String, target As String, password As String
      Dim file As Variant
      Dim cmd As String
      
      Application.DisplayAlerts = False
      Mstr = "C:\Users\Desktop\Test"
      
      For Each file In CreateObject("Scripting.FileSystemObject").GetFolder(Mstr).Files
      source = Chr$(34) & "C:\Users\Desktop\Test\" & file.Name & Chr$(34)
      
      target = "C:\Users\Desktop\Zipped\"
      password = Chr$(34) & "Abcd1234" & Chr$(34)
      cmd = """" & "C:\Program Files\PKWARE\PKZIPW\pkzipw.exe" & """" & " -add -pass=" & password & " " & target & " " & source
      Debug.Print cmd '' Copy command in Immediate window and paste in Command Prompt.
      
      Shell (cmd)
      
      Exit Sub ''Exit for testing
      Next
      Application.DisplayAlerts = True
    End Sub



    • Edited by mogulman52 Thursday, January 3, 2019 4:03 PM
    Thursday, January 3, 2019 3:49 PM