A tiny, single-file PowerShell script that adds a "Compress to tar.zst" entry to the Windows Explorer right-click menu for folders.
It uses the tar.exe shipped with Windows 10/11, which supports zstd natively via the -a (auto-compress by extension) flag — no third-party tools, no dependencies, no DLLs.
Right-click stuff\ → Compress to tar.zst → stuff.tar.zst
- Single file. One script does install, uninstall, and the actual compression payload.
- No dependencies. Uses built-in
tar.exe(Windows 10 1803+ / Windows 11). - Per-user install. Writes only to
HKCU— no admin rights needed. - Clean archives. Archives the folder's contents as
./..., notleaf/..., so extractors don't double-nest. - Quiet by default. Runs hidden; logs only when something goes wrong.
- Self-rotating log in
%TEMP%, capped at 1 MB, deleted on success. - Robust path handling. Works around PowerShell 5.1's
Split-Path -LiteralPath -Leafparameter-set bug, and Explorer's quoting quirks (paths with spaces, apostrophes, trailing backslashes).
- Windows 10 (1803+) or Windows 11 — must have
C:\Windows\System32\tar.exe. - Windows PowerShell 5.1 (preinstalled) or PowerShell 7+.
You can verify tar.exe supports zstd:
tar --help | Select-String zstd-
Download
CompressTarZstd.ps1. -
Open PowerShell in the folder containing it and run:
.\CompressTarZstd.ps1
If execution policy blocks it:
powershell -ExecutionPolicy Bypass -File .\CompressTarZstd.ps1
-
Right-click any folder in Explorer → Compress to tar.zst.
On Windows 11, the entry appears under Show more options (or Shift+Right-click) unless you've enabled the classic context menu.
The script can be moved or deleted after install — the right-click handler is self-contained in the registry (the payload is base64-encoded into the command).
.\CompressTarZstd.ps1 -uThis removes HKCU:\Software\Classes\Directory\shell\CompressTarZstd. Nothing else is touched.
The installer registers a single registry key:
HKCU\Software\Classes\Directory\shell\CompressTarZstd
(Default) = "Compress to tar.zst"
Icon = "shell32.dll,45"
\command
(Default) = cmd.exe /c set "CTZ_PATH=%1" && powershell.exe ...
The selected folder path is passed via the CTZ_PATH environment variable instead of as a PowerShell argument. This sidesteps PowerShell's argument parser entirely, which is the source of most "works for me / breaks on weird paths" pain in shell-extension scripts.
The compression payload then:
- Strips wrapping quotes and trailing backslashes from
CTZ_PATH. - Splits parent / leaf using
[System.IO.Path](avoids a PS 5.1 parameter-set bug). cds into the folder and runstar.exe -a -cf <leaf>.tar.zst ..- Writes the archive next to the source folder.
Resulting archive structure:
$ tar -tf stuff.tar.zst
./
./data.txt
./doxx.pdf
./eu-ai.txt
- Location:
%TEMP%\CompressTarZstd.log - Rotated at 1 MB; one previous copy kept as
CompressTarZstd.log.1. - Deleted on success so a healthy system has no log at all.
- If something fails, the log persists for inspection and the PowerShell window stays open for 5 seconds.
To inspect after a failure:
Get-Content $env:TEMP\CompressTarZstd.log- Folders only. The handler is registered on
Directory, not on individual files. Right-click a parent folder if you want to archive a single file. - No compression-level option.
tar -auses zstd defaults. If you want to tune it, replace the tar invocation with something like:(requires a standalone& tar.exe --use-compress-program="zstd -19" -cf "$leaf.tar.zst" .
zstd.exeinPATH). - No progress UI. It runs hidden. For huge folders, watch the archive file size grow in Explorer.
- Per-user only. Run from each user account that needs the entry, or adapt to
HKLMif you want a machine-wide install (requires admin).
Nothing happens when I click the menu entry.
Check %TEMP%\CompressTarZstd.log. If it doesn't exist, the registry entry probably isn't installed for the current user — re-run the installer.
tar.exe not found.
You're on a Windows version older than 1803, or System32 isn't in PATH. Update Windows.
Parameter set cannot be resolved using the specified named parameters.
This was a PS 5.1 bug in earlier versions of this script — make sure you're using the current release.
Archive contains foldername/ as the top-level entry.
You're using an older version. The current script archives . from inside the folder so entries start with ./.
CC0 - See LICENSE.
tar.exeon Windows is libarchive, which has supported zstd for years.- Thanks to PowerShell 5.1 for being the reason this script needs
[System.IO.Path]instead ofSplit-Path.