kz.exe Examples
kz.exe is KingZip's command-line tool. From the console you can compress, extract, list and integrity-test ZIP / 7z / TAR / GZ / BZ2 / XZ / KZ / WIM / Zipx and more. It's ideal for automating with batch files or PowerShell scripts.
Quick Start (TL;DR)
kz l archive.zip REM list contents kz x archive.zip -o:C:\Out -y REM extract (keep full paths) kz c -fmt:zip out.zip file1 dir1\ REM create ZIP (fast) kz c -fmt:7z -l:5 out.7z file1 dir1\ REM create 7z (LZMA2 mt) kz t archive.7z REM integrity test
kz or kz --help / kz -h / kz /? / kz help.
Commands at a Glance
| Command | Meaning | Notes |
|---|---|---|
a | Add files to archive | Add files to an existing archive |
c | Create new archive | New (or overwrite) |
d | Delete files from archive | Remove entries without extracting |
e | Extract (flat) | Ignore folder structure, files only |
l | List contents | Simple list |
v | Verbose list | Detailed (CRC, ratio, time, etc.) |
rn | Rename inside archive | Rename without extracting |
t | Test integrity | Integrity check (CRC + full data decode) |
x | eXtract (full path) | Keep folder structure (the common default) |
Basic syntax
kz <command> [<switches>...] <archive> [<files>...] [<path_to_extract>]
<command>exactly one (a/c/d/e/l/rn/t/v/x)<switches>zero or more (-l:5,-p:password,-y, etc. — order-independent)<archive>path to the archive to process<files>input/target file list (when compressing, or as a filter for partial extract/delete)<path_to_extract>extract location for some commands (or use-o:)
-- to stop switch scanning (everything after it is treated as a positional argument).
All Switches (Options)
| Switch | Meaning | Example |
|---|---|---|
-l:N | Compression level (0=Store, 1=Fastest, 3=Fast, 5=Normal (default), 7=Maximum, 9=Ultra) | -l:9 |
-r | Recurse subfolders (ON by default for c/a) | -r |
-r- | Recursion OFF | -r- |
-p:password | Password (ZIP default=ZipCrypto, 7z=AES-256, KZ=AES-256-CTR) | -p:s3cret |
-mem:method | ZIP encryption method (zipcrypto, aes128, aes192, aes256) | -mem:aes256 |
-o:folder | Extraction target folder | -o:D:\Out |
-y | Auto-Yes to all prompts (for automation scripts) | -y |
-aoa | Overwrite all on conflict | |
-aos | Skip all on conflict | |
-aou | Auto-rename on conflict (file (2).txt) | |
-fmt:format | Force archive format (when the extension doesn't match) | -fmt:7z |
-mm:method | ZIP compression method (deflate, deflate64, lzma, bzip2, ppmd) | -mm:deflate |
-v:size | Split-volume size (k/m/g suffix) | -v:100m |
-sfx[:module] | Create an SFX (self-extracting EXE) | -sfx or -sfx:7z.sfx |
-mmt[N] | CPU thread count (0=Auto, 0 if unspecified) | -mmt8 |
-bd | Turn off the progress display (for scripts) | -bd |
-target:auto | Auto-decide the folder when extracting | |
-target:name | Extract into a folder named after the archive | |
-- | Stop switch scanning | kz x in.zip -- -file.txt |
Values accepted by -fmt:: zip, 7z, tar, gz/gzip/tgz, bz2/tbz2, xz/txz, wim, kz/kip, zipx (zipx maps to internal ZIP).
-l: level → internal mapping
-l: | CompressionLevel | Notes |
|---|---|---|
0 | Store | No compression (store only) |
1 | Fastest | |
2, 3 | Fast | |
4, 5 | Normal | Default when -l: is omitted |
6, 7 | Maximum | |
8, 9 | Ultra |
Per-command Examples
3.1 l / v — list contents
REM simple list kz l photos.zip REM verbose (modified time, CRC, ratio, etc.) kz v backup.7z REM password-protected: -p required if headers are encrypted; otherwise the list shows without a password kz v secret.7z -p:password
3.2 t — integrity test
REM decode every entry and verify CRC kz t backup.7z REM password + auto-continue kz t secret.zip -p:password -y REM hide progress, results only kz t big.7z -bd
Exit code 0 = OK, non-zero = corrupted/error (see the Exit Codes table).
3.3 x — extract (keep folder structure)
REM extract to the current folder (default) kz x sources.zip REM to a specific folder kz x sources.zip -o:C:\workspace REM auto-Yes (don't ask before overwriting) kz x sources.zip -o:C:\workspace -y -aoa REM extract into a folder named after the archive (sources.zip -> C:\out\sources\) kz x sources.zip -o:C:\out -target:name REM partial extract (specific files/folders only) kz x sources.zip -o:C:\out src\main.c README.md REM password + auto-rename on conflict kz x archive.zip -p:password -aou
3.4 e — extract (flat, ignore folder structure)
REM flatten all files into one folder (subdir/foo.txt -> foo.txt) kz e archive.zip -o:C:\flat REM auto-rename when same-named files collide kz e archive.zip -o:C:\flat -aou
3.5 c — create a new archive
REM ZIP (auto-detected from the extension) kz c out.zip file1 file2 dir1 REM specify ZIP method + default level (5) kz c -fmt:zip -mm:deflate -l:5 out.zip file1 dir1\ REM 7Z (LZMA2 multithreaded) kz c -fmt:7z -l:5 out.7z file1 dir1\ REM ZIP password default: ZipCrypto kz c -fmt:zip -mm:deflate -l:5 -p:password secret.zip confidential\ REM ZIP AES-256 kz c -fmt:zip -mm:deflate -l:5 -p:password -mem:aes256 secret-aes.zip confidential\ REM 7Z maximum compression + password (AES-256) kz c -fmt:7z -l:9 -p:password secret.7z confidential\ REM non-recursive (don't descend into directories) kz c out.zip -r- topfile.txt some_dir\ REM split archive (100 MB each) kz c -v:100m parts.7z huge_folder\ REM SFX (self-extracting EXE — 7z only) kz c -fmt:7z -sfx installer.exe payload\ REM custom SFX module kz c -fmt:7z -sfx:custom.sfx out.exe payload\ REM limit to 8 CPU threads kz c -mmt8 out.zip dir\ REM TAR + GZ in one step (.tar.gz uses -fmt:gz or the .tgz extension) kz c out.tar.gz src\ kz c -fmt:tgz out.tgz src\ REM TAR + BZ2 kz c -fmt:bz2 out.tar.bz2 src\ kz c -fmt:tbz2 out.tbz2 src\ REM TAR + XZ kz c -fmt:xz out.tar.xz src\ REM WIM (Windows Imaging Format) kz c -fmt:wim sysimage.wim system\
3.6 a — add to an existing archive
REM add files to a ZIP/7z (recursive by default) kz a out.zip newfile.txt newdir\ REM overwrite all on conflict kz a out.zip changed_file.txt -aoa
.z01/.001), SFX (MZ signature), and header-encrypted 7z cannot be appended to (same behavior as 7-Zip).
3.7 d — delete entries inside an archive
REM delete a specific file from a ZIP (updates metadata only, no re-extract) kz d archive.zip docs\old.pdf REM delete an entire folder kz d archive.zip build\
3.8 rn — rename inside an archive
REM old -> new (pass one pair at a time) kz rn archive.zip src\old.cpp src\new.cpp REM multiple pairs at once kz rn archive.zip a.txt aa.txt b.txt bb.txt
Common Scenarios
4.1 Daily backup script (Batch)
@echo off
set DATE=%date:~0,4%%date:~5,2%%date:~8,2%
kz c -fmt:7z -l:7 -p:!secret! ^
"D:\backup\proj-%DATE%.7z" ^
"C:\projects\my_repo" ^
-bd -y
if errorlevel 1 echo BACKUP FAILED & exit /b 1
echo Done: D:\backup\proj-%DATE%.7z
-bdhides progress → clean logs-yauto-Yes → unattended runs-l:7Maximum (good speed/size balance)
4.2 Large-folder ZIP
REM ZIP with 16 threads (full CPU) kz c -mmt16 -l:5 huge.zip big_folder\
In Task Manager you can watch kz.exe CPU usage rise across 16 threads.
4.3 Split 7z in 100 MB volumes
kz c -fmt:7z -l:5 -v:100m bundle.7z src\ REM result: bundle.7z.001, bundle.7z.002, ...
4.4 SFX (self-extracting archive)
kz c -fmt:7z -sfx kingzip_payload.exe files\ REM when the user runs kingzip_payload.exe, the 7-Zip-zstd SFX extracts it
4.5 Structure-preserving extract + overwrite on conflict
kz x src.zip -o:D:\restore -y -aoa
4.6 Test then extract (automation)
kz t src.7z -bd && kz x src.7z -o:D:\out -y
&& runs the next command only when the previous one returns 0 (success). In PowerShell: if ($LASTEXITCODE -eq 0) { ... }.
4.7 Password ZIP — quick verification
kz l secret.zip -p:password > nul && echo OK || echo WRONG
4.8 Auto-try multiple password candidates
for %P in (pwd1 pwd2 pwd3) do @kz l x.zip -p:%P > nul 2>&1 && echo Found: %P && goto :end
:end
Environment Variables (tuning)
| Variable | Effect | Example |
|---|---|---|
KZ_PAR=1 | On kz x archive.zip, bypass UnifiedDecoder and go straight to ParallelExtractor (for benchmarking/measurement) | set KZ_PAR=1 && kz x huge.zip |
KZ_WRITERS=N | Writer thread count for ZIP extraction (1–16, default hw/2 capped at 4) | set KZ_WRITERS=8 |
KZ_TIMING=1 | Print per-stage extraction timing (performance analysis) | set KZ_TIMING=1 |
Thread-count defaults
-mmt0or unspecified: registryHKCU\Software\KingZip\MaxCoreCount(or the core count if absent). Cap 32 (MAX_WORKER_THREADS).-mmtN(N>0): force N threads.
Exit Codes
| Code | Meaning |
|---|---|
0 | OK |
1 | General error (e.g. file not found) |
2 | Argument error (after printing -h and exiting) |
7 | User cancelled |
8 | Out of memory |
| other | bit7z / decoder internal error code |
Use in scripts (Batch)
kz t in.zip -bd
if errorlevel 1 (
echo TEST FAILED
exit /b 1
)
PowerShell
& kz t in.zip -bd
if ($LASTEXITCODE -ne 0) { Write-Host "FAILED" -ForegroundColor Red }