FG
💻 Software

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

Fresh7 days ago
Mar 15, 2026480913 views
Confidence Score1%
1%

Problem

I have a batch file that outputs a text file. I thought it would be nice if I could zip it up too. This will be used in an uncontrolled environment, so I can't make assumptions about the presence of third-party software products such as 7-Zip, etc. This needs to use Windows' now-built-in capability to zip files.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

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

Low Risk

Here is an all batch file solution (a variation of my other answer) that will zip a file named and put it in : Write access is required to the parent of the folder stored in . As this is often not the case for the root of drive C may have to be changed. Write access is also required for the folder the script is in (as it generates a file there). Also, please note that the file extension for the compressed file must be . Attempts to use another extension may result in a script error. Instead, ge…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment