6

I have 7-Zip installed, and it works from Windows, but not from the DOS prompt or command line:

7z e  max_logs_can_messages.tgz

Yields:

'7z' is not recognized as an internal or external command,
operable program or batch file.
3
  • It's 7za.exe, if I remember correctly. – Blender Apr 11 '13 at 17:18
  • 7za e max_logs_can_messages.tgz yields same error message – jdl Apr 11 '13 at 17:23
  • @Blender: 7zFM.exe is the 7-Zip File Manager. 7z.exe is the command-line version of 7-Zip. 7z.exe uses 7z.dll from the 7-Zip package, that's used by 7zFM.exe too. 7za.exe (a = alone) is the standalone version of 7-Zip. 7za.exe supports only 7z, lzma, cab, zip, gzip, bzip2, Z and tar formats. 7za.exe doesn't use external modules. tl;dr: 7z.exe or 7za.exe will both work at the command line, but 7za.exe doesn't have any external dependencies. – Karan Apr 11 '13 at 21:35
8

You'll need to add the binary to your machine's PATH

See more here: http://www.7-zip.org/faq.html

2
  • Half right - definitely need the path variable, or to be in that directory, or to use the fully qualified path of 7z.exe, but with Windows, you do not need to include the extension on exe files. – Joe Enos Apr 11 '13 at 18:55
  • Updated my answer, Joe Enos, thanks. – Screenack Apr 11 '13 at 19:04
3

You can either copy 7-Zip to a well-known path like these:

C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem

or you call 7-Zip with the full path:

C:\Program Files\7-Zip\7z.exe

Or you do the thing Screenack said ;)

1

You need to register 7-Zip as a system PATH environment variable. An easy way to do this in Windows 7 & 8 is to run this from the command line:

setx path "%path%;C:\Program Files\7-Zip"
1

You need to add the 7-Zip folder to your PATH:

setx /M path "%path%;C:\Program Files\7-Zip\"

Alternatively, for Easy 7-Zip:

setx /M path "%path%;C:\Program Files\Easy 7-Zip\"
2
  • If you want only a temporary change to the PATH, I believe you could run the following command between the quotes instead: "set PATH=%PATH%;C:\Program Files\7-Zip\" . See superuser.com "What is the difference between SETX and SET in environment variables in Windows" for the difference between the set and setx command. – AGéoCoder Jul 21 '20 at 20:17
  • Messed up my system path when run from Powershell. Guess this is only meant for running from cmd prompt? – Chad Oct 24 '20 at 8:47
0

while zipping in cmd or git bash - getting error like

7z:command not found 

solution:

  • install 7z in your machine
  • set the path in Environment Variables -> User Variables
  • path -> edit -> new (add the path - C:\Program Files\7-Zip) -> OK

Now to use 7z in git Bash

  • Go to C:\Program Files\7-Zip and copy 7z.exe file
  • Go to C:\Program Files\Git\usr\bin and paste 7z.exe file

Now, you will be able to use 7z with Git Bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.