Does Windows have a built-in ZIP command for the command line?

Solution 1:

It's not built into Windows, but it's in the Resource Kit Tools as COMPRESS,

C:\>compress /?

Syntax:

COMPRESS [-R] [-D] [-S] [ -Z | -ZX ] Source Destination
COMPRESS -R [-D] [-S] [ -Z | -ZX ] Source [Destination]

Description:
Compresses one or more files.

Parameter List:
-R Rename compressed files.

-D Update compressed files only if out of date.

-S Suppress copyright information.

-ZX LZX compression. This is default compression.

-Z MS-ZIP compression.

Source Source file specification. Wildcards may be
used.

Destination Destination file | path specification.
Destination may be a directory. If Source is
multiple files and -r is not specified,
Destination must be a directory.

Examples:

COMPRESS temp.txt compressed.txt
COMPRESS -R *.*
COMPRESS -R *.exe *.dll compressed_dir

Solution 2:

Not that I'm aware of. As far as third party tools goes, 7zip has a pretty nice command line interface and the binary can be distributed with your app in the app's directory, so you don't have to rely on it being installed ahead of time.


Solution 3:

Powershell does. See:

Compress Files with Windows PowerShell then package a Windows Vista Sidebar Gadget


Solution 4:

.Net 4.5 has this functionality built in, and it can be leveraged by PowerShell. You'll need to be on Server 2012, Windows 8, or have .Net 4.5 installed manually.

[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
$Compression = [System.IO.Compression.CompressionLevel]::Optimal
$IncludeBaseDirectory = $false

$Source = "C:\Path\To\Source"
$Destination = "C:\CoolPowerShellZipFile.zip"

[System.IO.Compression.ZipFile]::CreateFromDirectory($Source,$Destination,$Compression,$IncludeBaseDirectory)

Solution 5:

Another solution found on superuser site use windows native com object in .bat file:

Can you zip a file from the command prompt using ONLY Windows' built-in capability to zip files?