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 filenamed C:\someArchive.zip
containing all files in folder C:\test3
:
CScript zip.vbs C:\test3 C:\someArchive.zip
Where file zip.vbs
contains:
' Get command-line arguments.Set objArgs = WScript.ArgumentsSet FS = CreateObject("Scripting.FileSystemObject")InputFolder = FS.GetAbsolutePathName(objArgs(0))ZipFile = FS.GetAbsolutePathName(objArgs(1))' Create an 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).ItemsobjShell.NameSpace(ZipFile).CopyHere(source)' Required to let the ZIP command execute' If this script randomly fails or the ZIP file is not complete,' just increase to more than 2 secondswScript.Sleep 2000
I haven't tested it for paths and file names containing spaces. It may work if quotesare 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.