WinZip command line and unzip script

Winzip provides a command line add-on that you can use if you have a licensed version of WinZip. (For download goto: ) This comes very handly when you need to unzip files from your program. In my case, I wrote a small VB Script file (scheduled to run using my scheduler as part of a batch job) . Below given is the script. it unzips to a specified directory, uses WScript and Shell object.

Option Explicit
On Error Resume Next

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count 2 Then
WScript.Echo "Usage: zUnzip <ZIP FILENAME> <PATH TO UNZIP>"
End if

Dim ZipFileName
Dim PathName
ZipFileName = oArgs.Item(0)
PathName = oArgs.Item(1)

'Unzip given zip file to specified path
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
Dim cmdScript
cmdScript = "%comspec% /c wzunzip.exe " & ZipFileName & " " & PathName
objShell.Run(cmdScript), 1, True


Some points worth mentioning,

objShell.Run(cmdScript), 1, True

In this command, second parameter for the Run Method is window style, if it is 1 it shows a window, use 0 for not showing the command window
Also note %comspec% /c in the command, this variable gets you the command interpreter for your OS, for example for Win2K, it gives you “cmd” and /C switch closes the secondary session after execution.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s