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?

  • 6
    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
    Commented Jul 5, 2012 at 20:20
  • 3
    Not sure why this is closed as its the first hit on google for "windows 2008 zip"
    – AlSki
    Commented Nov 27, 2012 at 8:46
  • 2
    ^I feel the same way (clearly), especially considering the accepted answer. Commented Feb 25, 2013 at 19:33
  • 1
    On Windows 7 you can also use compact
    – jyz
    Commented May 13, 2013 at 14:52
  • Windows built-in compress/decompress utils - stackoverflow.com/questions/28043589/…
    – npocmaka
    Commented Jan 25, 2015 at 15:32

7 Answers 7


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

C:\>compress /?


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

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

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.


COMPRESS temp.txt compressed.txt
COMPRESS -R *.exe *.dll compressed_dir
  • 1
    Wrong link! Correct links is: microsoft.com/downloads/… Commented Aug 26, 2009 at 10:07
  • 1
    Can this be used on windows server 2008, too?
    – BMBM
    Commented Dec 8, 2009 at 15:43
  • 8
    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
    Commented Jun 21, 2010 at 18:21
  • Anyone else get "The compressed (Zipped) folder is invalid or corrupted" when you double-click the file compressed with this method?
    – user37944
    Commented Jul 1, 2011 at 6:15
  • 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.
    – user11604
    Commented Jul 1, 2011 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.

  • 1
    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. Commented Jul 10, 2009 at 21:50
  • 6
    Like I said, you don't have to install it. Copy the binary to a folder somewhere and run it from there.
    – Chris
    Commented Jul 10, 2009 at 22:54
  • 2
    Well, you and I don't consider that installing. The IT manager in question does, though, if you know what I mean. :) Commented Jul 11, 2009 at 18:53
  • 2
    Ha, so run the 7zip binary from a remote network share :) Commented Feb 25, 2013 at 19:50
  • From my employer's "Acceptable Use Agreement": (7) Improper Conduct While Using {company's} IT Assets. (h) Downloading and/or installing unauthorized software, applications or programs. (10) Failure to Comply (a) {company} employees failing to meet this policy may be subject to disciplinary actions, including termination and legal proceedings. Commented Mar 19, 2021 at 14:05

Powershell does. See:

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

  • Sweet! I figured there must also be a powershell solution. Commented Jul 11, 2009 at 18:53
  • This is not a command, but a series of scripts. It works though.
    – cowlinator
    Commented Apr 27, 2019 at 0:25
  • This url is now broken.
    – cowlinator
    Commented Apr 21, 2020 at 20:49
  • As of 2023-02-22 - The URL in the post not goes to the archive.org wayback machine version of the page.
    – qxotk
    Commented Feb 23, 2023 at 14:49

.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.

$Compression = [System.IO.Compression.CompressionLevel]::Optimal
$IncludeBaseDirectory = $false

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


Update - Build 1803 (March 2018)

Per What's new for the Command Line in Windows 10 version 1803, windows now ships with tar.exe built-in, which you can use like this:

C:\temp> tar.exe -xf files.zip

Further Reading

  • The results are not compatible with Windows unzip and other tools.
    – cskwg
    Commented Jun 23, 2022 at 8:27

There is a single, simple PowerShell command for this. (PowerShell v5.0+)

To zip:

Compress-Archive -LiteralPath 'C:\mypath\testfile.txt' -DestinationPath "C:\mypath\Test.zip"

To unzip:

Expand-Archive -LiteralPath "C:\mypath\Test.Zip" -DestinationPath "C:\mypath" -Force


Special thanks to @Ramhound

  • 1
    Yes, I was doing a CMD script to run in several windows machine from all kind of versions. The only cross platform command that will work without needing .net or toolkits installed is powershell You can run a simplified command line like: powershell Compress-Archive . publish.zip
    – DefToneR
    Commented Sep 17, 2021 at 15:23

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?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .