Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Since Windows Explorer (since at least Windows XP) has some basic support for ZIP files, it seems like there should be a command-line equivalent, but I can't seem to find any sign of one.

Does Windows (XP, Vista, 7, 8, 2003, 2008, 2013) ship with a built-in command-line zip tool, or do I need to stick with third-party tools?

share|improve this question
4  
I'm not entirely sure why this question is closed. This comes up frequently in the form of "How do I compress my logs?", which is definitely "Operations, maintenance, and monitoring". The question could be rephrased to be narrower, I suppose, but the solutions are general. –  alficles Jul 5 '12 at 20:20
3  
Not sure why this is closed as its the first hit on google for "windows 2008 zip" –  AlSki Nov 27 '12 at 8:46
2  
^I feel the same way (clearly), especially considering the accepted answer. –  Electrons_Ahoy Feb 25 '13 at 19:33
1  
On Windows 7 you can also use compact –  jyz May 13 '13 at 14:52

5 Answers 5

up vote 47 down vote accepted

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
share|improve this answer
    
Snap! There we go! Thanks! –  Electrons_Ahoy Jul 10 '09 at 21:49
1  
Wrong link! Correct links is: microsoft.com/downloads/… –  Lars Fastrup Aug 26 '09 at 10:07
1  
Can this be used on windows server 2008, too? –  Max Dec 8 '09 at 15:43
5  
This is a far cry from a usable ZIP client. You cannot compress folders and there appears to be no way to add compressed files to an existing archive. Avoid. –  roufamatic Jun 21 '10 at 18:21
4  
Compress isn't actually a ZIP client. It creates those files that you used to find on MS-DOS and Windows 3.11/95 installation disks. e.g. WINSOCK.DL_ expands to WINSOCK.DLL. You can unpack the files using expand. –  Bryan Jul 1 '11 at 15:55

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.

share|improve this answer
    
I'm a big fan of 7Zip, but the current issue is on a machine that I don't have install rights on, and there isn't a 3rd party zip widget installed. Thanks, though. –  Electrons_Ahoy Jul 10 '09 at 21:50
5  
Like I said, you don't have to install it. Copy the binary to a folder somewhere and run it from there. –  Chris Jul 10 '09 at 22:54
1  
Well, you and I don't consider that installing. The IT manager in question does, though, if you know what I mean. :) –  Electrons_Ahoy Jul 11 '09 at 18:53
2  
Ha, so run the 7zip binary from a remote network share :) –  Brent Pabst Feb 25 '13 at 19:50

Powershell does. See:

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

share|improve this answer
    
Sweet! I figured there must also be a powershell solution. –  Electrons_Ahoy Jul 11 '09 at 18:53

.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)
share|improve this answer

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?

share|improve this answer

protected by Iain Feb 3 '12 at 15:49

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.