'7z', 'zip', 'unzip' is not recognized as internal command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
7 min

banner

# Table of Contents

  1. '7z' is not recognized as an internal or external command
  2. 'zip' is not recognized as an internal or external command
  3. 'unzip' is not recognized as an internal or external command

# '7z' is not recognized as an internal or external command

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.

7z is not recognized as internal or external command

If you have Chocolatey installed:

  1. Click on the Search bar and type PowerShell.

  2. Right-click on the PowerShell application and click "Run as administrator".

run powershell as administrator

  1. Run the following command to install 7-Zip.
PowerShell
choco install 7zip.install -y

chocolatey install 7zip

If you don't have Chocolatey installed, you have to install it first.

To install Chocolatey:

  1. Open PowerShell as an administrator.

run powershell as administrator

  1. Run the following command.
PowerShell
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'))

windows install chocolatey

  1. Wait for the command to complete.
  2. Type choco to make sure Chocolatey is installed.

windows verify chocolatey installed

Now that you have Chocolatey installed, run the following command to install 7-Zip.

PowerShell
choco install 7zip.install

Note that your shell should still be run using elevated permissions.

chocolatey install 7zip

Now you should be able to use the 7z command.

Click on the Search bar, type "cmd" and start the Command Prompt application.

cmd
# ๐Ÿ‘‡๏ธ extract the archive 7z e archive.zip

7z extract archive

You can use the 7z a command to create an archive.

cmd
7z a -t7z files.7z my-folder

7z create archive

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

# Download and install 7-Zip on Windows

  1. If you are unsure whether your computer runs 32-bit or 64-bit:
  • Click on the Start button, then click Settings > System > About.
  • Look at the value of "System type".

windows check if 32 64 bit

  1. Download the 7-Zip .exe file for your system (it will most likely be the 64-bit Windows x64 .exe file).

download 7zip executable

  1. Start the installer. Note that you might have to change your app recommendation settings by clicking on "Change my app recommendation settings".

change app recommendation settings

  1. Leave the default destination folder selected and click "Install".

select destination folder

  1. Once the installation process is complete, restart your Command Prompt and try using the 7z command.
cmd
# ๐Ÿ‘‡๏ธ extract the archive 7z e archive.zip

7z extract archive

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.

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Click on "New" and then click "Browse".

click new browse

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

7 zip location

We are looking for the directory that contains the 7z.exe file because that is the file that is executed using the command line.

  1. Add the path to 7-Zip and click on "OK" twice to confirm.

  2. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

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.

cmd
# ๐Ÿ‘‡๏ธ extract the archive 7z e archive.zip

7z extract archive

You can use the following command to create an archive.

cmd
# ๐Ÿ‘‡๏ธ create a files.zip archive 7z a -tzip files.zip my-folder

7z create zip file

And the following command to extract an archive.

shell
# ๐Ÿ‘‡๏ธ extract the archive 7z x files.zip

7z extract zip archive

# Table of Contents

  1. 'zip' is not recognized as an internal or external command
  2. 'unzip' is not recognized as an internal or external command

# 'zip' is not recognized as an internal or external command

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.

zip is not recognized as internal or external command

The zip command is not available in a Windows shell, but you can use the tar command in Windows 10.

cmd
# ๐Ÿ‘‡๏ธ 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.

using tar command to zip

And here is a screenshot of uncompressing using tar.

cmd
tar -zxvf files.zip

unzip using tar command

You can issue the tar --help command to look at the parameters the command supports.

cmd
tar --help
NameDescription
cCreate an archive
vVerbose mode
zCompress the archive with gzip
fLocation of the archive
xExtract (uncompress) an archive

You can also specify file names or patterns.

cmd
# ๐Ÿ‘‡๏ธ 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.

cmd
# ๐Ÿ‘‡๏ธ 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.

# Using PowerShell's Compress-Archive and Expand-Archive commands

To open PowerShell:

  1. Click on the Search bar and type "PowerShell".
  2. Start the PowerShell application.

The syntax for the Compress-Archive command is the following.

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

PowerShell
Compress-Archive -Path C:\Users\Public\bobbyhadz -DestinationPath files.zip

compress archive powershell

You can also use a dot to compress the files in the current directory.

PowerShell
Compress-Archive -Path . -DestinationPath files.zip

compress archive current directory

You can use the Expand-Archive command to extract files from an archive.

PowerShell
Expand-Archive -Path files.zip -DestinationPath C:\Users\Public\bobbyhadz

extract contents of archive

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.

PowerShell
Get-Help Compress-Archive Get-Help Expand-Archive

# 'unzip' is not recognized as an internal or external command

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 is not recognized as internal or external command

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

PowerShell
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

powershell use expand archive command

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:

  1. Search for Git Bash and start the application.

search for git bash

  1. Run the command in the Git Bash shell.
GitBash
unzip my-zip-file.zip

unzip file using git bash

You can use the -d parameter if you need to specify the destination directory.

GitBash
unzip my-zip-file.zip -d my-destination-folder

unzip file with destination in git bash

If you don't have Git Bash, you have to download and install git.

# Downloading and installing git on Windows

To download git and be able to use Git Bash:

  1. Open the git downloads page and download the installer for Windows.
  2. Start the installer.
  3. You will be prompted to select a destination location. You can leave the default option and click Next.

git select destination location

  1. You will be prompted to select components on the next screen. Leave the default options and click Next.

git select components

  1. Click Next on the screen that prompts you to "Select Start Menu Folder".

  2. On the next screen, you can choose the default editor for Git, e.g. Notepad, Notepad++ or any other editor you prefer.

choose git default editor

  1. On the "Adjust the name of the initial branch in new repositories screen", click Next.

adjust name of initial branch

  1. On the "Adjust your PATH environment" screen, make sure you have the default option of "Git from the command line and also from 3rd-party software" option selected and click "Next".

adjust your path environment

  1. For all the remaining screens, leave the default option selected and click Next.
  2. Lastly, click on the Install button to install git.

Once you have git installed, click on the Search field, type "Git Bash" and start the application.

search for git bash

Now you can issue the unzip command.

GitBash
unzip my-zip-file.zip

unzip file using git bash

You can use the -d parameter if you need to specify the destination directory.

GitBash
unzip my-zip-file.zip -d my-destination-folder

unzip file with destination in git bash

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

  1. Open the folder in a new window.
  2. Right-click in Explorer.

search for git bash

  1. Click "Git Bash Here".

  2. Run the command in the specific directory.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev