WinZip Command Line Information

WinZip Code Sample

'FolderN = path to folder including sub directories you wish to zip
'MPW = optional password specified for securing the file contents.
'this password setting has the benefit that every file included will be secured.
'PW = True if you use a password. Dont forget to add a password

'RULES FOR PASSWORDS ARE SPECIFED IN THE HELP FILE FOR WINZIP

'will only zip complete folders and sub directories and all encompassed files.


Function ZipMe(ByVal FolderN As String,Optional MPW As String = "" Optional PW As Boolean = True)
Dim Tmpzip As String, FN As Integer


If Right(FolderN, 1) = "\" Then
FolderN = Left(FolderN, Len(FolderN) - 1)

If FolderN = "C:\" Or FolderN = "C:\Windows" Or _
InStr(1, FolderN, "C:\Windows") <> 0 Then
MsgBox "WARNING! You can not compress and protect system related folders." & vbCrLf & vbCrLf & _
"Please read the help files for more detailed information before proceeding with the use of the application." & vbCrLf & vbCrLf & _
"This error is caused by an attempt to compress the folder [" & FolderN & "]", vbCritical, "SYSTEM WARNING!"
Exit Function
End If

End If
Tmpzip = FolderN & ".zip"

PWProt = ""

If PW = True Then
PWProt = "-s" & MPW & " "
End If

Call Shell("C:\Program Files\WinZip\winzip32 -min -a -ex -r " & PWProt & _
Tmpzip & " " & FolderN, vbHide)
End Function


' DESCRIPTION!

'This text is an excerpt formatted for inclusion in a Visual Basic project Module
'   Source: http://www.winzip.com/xcmdline.htm

'WinZip is a registered trademark of WinZip Computing, Inc.

'==================================================================

'There is also a Command Line Addon available for download from

'   http://www.winzip.com/wzcline.htm

'==================================================================
'A Note from WinZip Computing Inc.
'==================================================================
'Webmasters, please note this distribution restriction:
'Unless you have prior written authorization from WinZip Computing, Inc.,
'you are not authorized to distribute copies of this add-on.
'Please refer anyone interested in the add-on to the WinZip web site
'to be sure they get the most recent version.

'==================================================================

'Adding Files
'==================================================================
'The command format is:

'winzip32 [-min] action [options] filename[.zip] files

'where:

'------------

'   -min specifies that WinZip should run minimized.
'   If -min is specified, it must be the first command line parameter.

'Action
'------------
'   -a for add
'   -f for freshen
'   -u for update
'   -m for move.

'   You must specify one (and only one) of these actions.
'   The actions correspond to the actions described in
'   the section titled "Add dialog box Options " in the online manual.

'Options
'------------

'   -r corresponds to the Include subfolders checkbox
'   in the Add dialog and causes WinZip to add files
'   from subfolders. Folder information is stored for files added from subfolders.
'
'   If you add -p, WinZip will store folder information for all files added,
'   not just for files from subfolders; the folder information will
'   begin with the folder specified on the command line.
'
'compression method:
'------------

'   -ex = Extra
'   -en = Normal    (DEFAULT)
'   -ef = Fast
'   -es = Super Fast
'   -e0 = No Compression


'-hs includes hidden and system files.

'   Use -sPassword to specify a case-sensitive password.
'   The password can be enclosed in quotes, for example, -s"Secret password "

'   filename.zip Specifies the name of the Zip file involved.
'   Be sure to use the full filename (including the folder).

'Files
'------------
'   Is a list of one or more files, or the @ character followed by
'   the filename containing a list of files to add, one filename per line.
'   Wildcards (e.g. *.bak) are allowed.


'Extracting Files
'==================================================================

'The command format is:

'   winzip32 -e [options] filename[.zip] folder

'where

'-e is required.

'Options
'------------

'   -o = "Overwrite existing files without prompting"
'   -j = "Junk pathnames", respectively.

'   Unless -j is specified, folder information is used.
'   Use -sPassword to specify a case-sensitive password.
'   The password can be enclosed in quotes, for example, -s"Secret Password".

'filename.zip
'------------

'   Specifies the name of the Zip file involved.
'   Be sure to specify the full filename (including the folder).

'folder
'------------

'   Is the name of the folder to which the files are extracted.
'   If the folder does not exist it is created.


'=VERY IMPORTANT:=================================================================
'
'   always specify complete filenames,
'   including the full folder name and drive letter, for all file IDs.
'
'   To run WinZip in a minimized inactive icon use the "-min" option.
'   When specified this option must be the first option.
'
'   Only operations involving the built-in zip and unzip are supported.
'
'   Enclose long filenames in quotes.
'
'   When using a list ("@") file, no leading or trailing spaces should appear in file IDs in the list.
'
'   The action and each option must be separated by at least one space.
'
'   WinZip can be used to compress files with cc:Mail .
'   Change the compress= line in the [cc:Mail] section of
'   the appropriate WMAIL.INI files to specify
'   the full path for WinZip followed by "-a %1 @%2".
'
'   For example, if WinZip is installed in your c:\winzip folder, specify
'
'       compress=c:\winzip\winzip.exe -a %1 @%2
'

You might also like...

Comments

Mike J

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry