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.

Is there such a creature, or do I need to stick with third-party tools?

link|improve this question

71% accept rate
feedback

closed as off topic by Iain Feb 3 at 15:49

Questions on Server Fault are expected to generally relate to servers, networking, or desktop infrastructure, within the scope defined in the faq.

7 Answers

up vote 32 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
link|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
Thanks Lars, I've updated the link. – Bryan Aug 26 '09 at 12:21
1  
Can this be used on windows server 2008, too? – Max Dec 8 '09 at 15:43
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
show 2 more comments
feedback

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.

link|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
feedback

Powershell does. See:

http://blogs.msdn.com/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx

JR

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

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

http://superuser.com/questions/110991/can-you-zip-a-file-from-the-command-prompt-using-only-windows-built-in-capabili

link|improve this answer
feedback

It should be "COMPACT.EXE". It can be found in C:\WINDOWS\SYSTEM32 and is already in the PATH environment. No need to use those from the resources kit.

http://technet.microsoft.com/en-us/library/bb490884.aspx

link|improve this answer
2  
This doesn't actually create a zip archive - it simply toggles the "Compress" bit for a given folder/file on an NTFS partition. – Goyuix Oct 8 '10 at 2:37
feedback

Take a look at WinZip Command Line. http://www.winzip.com/prodpagecl.htm

It's not part of Windows, but it works.

Alternatively, you could write your own using Python.

link|improve this answer
It also requires a valid WinZip license: "The WinZip® Command Line Support Add-On is a FREE add-on for users of WinZip with a valid license" – jamiebarrow Jun 7 '11 at 5:36
feedback

I was a fan of 7zip, but have switch to using WinRAR, solely for the reason that I can script the creation and updating of self extracting zips with WinRAR easier than I can with 7zip.

Yes I know 7zip does it, however after hours of trying to get it to work properly, I tried WinRAR and within 15mins had it working. http://www.rarlab.com/rar_archiver.htm

link|improve this answer
feedback

protected by Iain Feb 3 at 15:49

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

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