Last updated: Apr 4, 2024
Reading timeยท7 min

The error "'7z' is not recognized as an internal or external command, operable
program or batch file" occurs when we try to use the 7z command without having
7-Zip installed.
To solve the error, install 7-Zip using Chocolatey or the official installer.

If you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".

7-Zip.choco install 7zip.install -y

To install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco to make sure Chocolatey is installed.
Now that you have Chocolatey installed, run the following command to install
7-Zip.
choco install 7zip.install
Note that your shell should still be run using elevated permissions.

Now you should be able to use the 7z command.
Click on the Search bar, type "cmd" and start the Command Prompt application.
# ๐๏ธ extract the archive 7z e archive.zip

You can use the 7z a command to create an archive.
7z a -t7z files.7z my-folder

Alternatively, you can install 7-zip using the official installer.

.exe file).


7z command.# ๐๏ธ extract the archive 7z e archive.zip

If you get the error: "'7z' is not recognized as an internal or external
command, operable program or batch file", you have to add the path to 7-Zip
to your PATH environment variable.




7-Zip directory will most likely be located under the following path.C:\Program Files\7-Zip

We are looking for the directory that contains the 7z.exe file because that is
the file that is executed using the command line.
Add the path to 7-Zip and click on "OK" twice to confirm.
Close your Command prompt application and then reopen it.
You might also have to restart your PC, but that's not always necessary.
Open a new CMD shell and try running the 7z command.
# ๐๏ธ extract the archive 7z e archive.zip

You can use the following command to create an archive.
# ๐๏ธ create a files.zip archive 7z a -tzip files.zip my-folder

And the following command to extract an archive.
# ๐๏ธ extract the archive 7z x files.zip

The error "'zip' is not recognized as an internal or external command,
operable program or batch file" occurs when we use the zip command on
Windows.
To solve the error, use the tar command or the PowerShell Compress-Archive
command.

The zip command is not available in a Windows shell, but you can use the tar
command in Windows 10.
# ๐๏ธ zip using the `tar` command tar -cvzf files.zip my-folder # ๐๏ธ extract using the `tar` command tar -zxvf files.zip
Here is a screenshot of compressing using tar.

And here is a screenshot of uncompressing using tar.
tar -zxvf files.zip

You can issue the tar --help command to look at the parameters the command
supports.
tar --help
| Name | Description |
|---|---|
c | Create an archive |
v | Verbose mode |
z | Compress the archive with gzip |
f | Location of the archive |
x | Extract (uncompress) an archive |
You can also specify file names or patterns.
# ๐๏ธ compress the files tar -cvzf files.zip index.js package.json # ๐๏ธ extract the archive tar -zxvf files.zip
Or compress all of the files in the directory.
# ๐๏ธ compress the files in the current directory tar -cvzf files.zip . # ๐๏ธ extract the archive tar -zxvf files.zip
Alternatively, you can use the PowerShell Compress-Archive command.
To open PowerShell:
The syntax for the Compress-Archive command is the following.
Compress-Archive -Path C:\Users\your_user\my-folder -DestinationPath files.zip
Here is an example that creates a zip file with the contents of a directory.
Compress-Archive -Path C:\Users\Public\bobbyhadz -DestinationPath files.zip

You can also use a dot to compress the files in the current directory.
Compress-Archive -Path . -DestinationPath files.zip

You can use the Expand-Archive command to extract files from an archive.
Expand-Archive -Path files.zip -DestinationPath C:\Users\Public\bobbyhadz

The Compress-Archive and Expand-Archive commands only work in PowerShell.
You can check out the parameters the commands take and other examples of using them in the following sections of the docs:
You can also use the Get-Help command to print the supported parameters.
Get-Help Compress-Archive Get-Help Expand-Archive
The error "'unzip' is not recognized as an internal or external command,
operable program or batch file" occurs when we use the unzip command on
Windows, in a CMD shell.
To solve the error, use the command in Git Bash or use the PowerShell
Expand-Archive command.

unzip command isn't supported on Windows, in CMD and PowerShell. However, you can use it in Git Bash.A Windows alternative to unzip is to use the
Expand-Archive
PowerShell command.
Expand-Archive -Path Draftv2.zip -DestinationPath C:\Reference # ๐๏ธ if the file name contains parameters, use `LiteralPath` Expand-Archive -LiteralPath 'C:\Archives\Draft[v1].zip' -DestinationPath C:\Reference

You can check out the syntax, parameters and examples of using Expand-Archive
in
this section
of the docs.
Alternatively, you can use the unzip command in Git Bash.
If you already have git installed, you can:
Git Bash and start the application.
unzip my-zip-file.zip

You can use the -d parameter if you need to specify the destination directory.
unzip my-zip-file.zip -d my-destination-folder

If you don't have Git Bash, you have to download and install git.
git on WindowsTo download git and be able to use Git Bash:
Next.
Next.
Click Next on the screen that prompts you to "Select Start Menu Folder".
On the next screen, you can choose the default editor for Git, e.g.
Notepad, Notepad++ or any other editor you prefer.

Next.

Next.Install button to install git.Once you have git installed, click on the Search field, type "Git Bash"
and start the application.

Now you can issue the unzip command.
unzip my-zip-file.zip

You can use the -d parameter if you need to specify the destination directory.
unzip my-zip-file.zip -d my-destination-folder

If you need to open Git Bash in a specific folder:

Click "Git Bash Here".
Run the command in the specific directory.