It is possible to zip files without installation of any additional
software (I have tested it). The solution is:
Run this in a command-line window to create a zip file
C:\someArchive.zip containing all files in folder
CScript zip.vbs C:\test3 C:\someArchive.zip
'Get command-line arguments.
Set objArgs = WScript.Arguments
InputFolder = objArgs(0)
ZipFile = objArgs(1)
'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
Set objShell = CreateObject("Shell.Application")
Set source = objShell.NameSpace(InputFolder).Items
I haven't tested it for paths and file names containing spaces. It may work if quotes
are put around the command line parameters.
How it works: the built-in zip functionality in Windows (Windows XP and later?) is
exposed through COM interfaces from the Windows shell
, explorer.exe - that is the "Shell.Application" part. This COM interface can be used from a VBScript script because
such a script can access COM components. To make the script fully self-contained it creates
an empty ZIP file to get started (one could also create an empty ZIP file and copy it to the target system along with the VBScript script).
VBScript has been installed by default in every desktop
release of Microsoft Windows since Windows 98.
CScript.exe is part of Windows Script Host.
Windows Script Host is distributed and installed by default on Windows 98 and later versions of Windows. It is also installed if Internet Explorer 5 (or a later version) is installed.