问题描述
我尝试通过 CMD 解压缩文件.
I try to unzip a file via CMD.
所以我安装了 WinZip(以及它的 cmd 插件)、WinRAR 和 7-zip.
So I install WinZip (and its plugin to cmd), WinRAR, and 7-zip.
但是当我尝试通过 CMD 执行命令时:
But when I try to execute a command via the CMD:
7z e myzip.zip
它给出了下一个错误:
7z is not recognized as an internal or external command
另外,我在环境变量(属性-->高级-->环境变量-->用户变量-->选择路径中添加了7-z的文件夹,并添加C:Program Files7-邮编
In addition, I added the folder of 7-z to the environment variables (Properties--> advanced --> Environment Variables --> user variable --> choose path, and add C:Program Files7-Zip
可能是什么原因?
我找到了以下解决方案.
在 cmd 或 git bash 中压缩时 - 收到类似
while zipping in cmd or git bash - getting error like
7z:command not found
解决办法:
- 在你的机器上安装 7z
- 在 Environment Variables -> User Variables 中设置路径
- 路径 -> 编辑 -> 新建(添加路径 - C:ProgramFiles7-Zip) -> 确定
现在在 git bash 中使用 7z -
Now to use 7z in git bash -
- 转到 C:Program Files7-Zip 并复制 7z.exe 文件
- 转到 C:Program FilesGitusrin 并粘贴 7z.exe 文件
现在,您将能够在 Git Bash 中使用 7z
Now, you will be able to use 7z with Git Bash
推荐答案
在命令提示符下执行以下操作对我有用,同时添加到我的用户环境变量也能正常工作:
Doing the following in a command prompt works for me, also adding to my User environment variables worked fine as well:
set PATH=%PATH%;C:Program Files7-Zip echo %PATH% 7z
您应该看到输出(或类似的东西 - 因为这是在我运行 Windows 7 的笔记本电脑上):
You should see as output (or something similar - as this is on my laptop running Windows 7):
C:UsersPhillip>set PATH=%PATH%;C:Program Files7-Zip C:UsersPhillip>echo %PATH% C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Wi ndowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntel WirelessCommon;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100To olsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Fil es (x86)QuickTimeQTSystem;C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Notepad+ +;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWirelessCommon;C:Program Files7-Zip C:UsersPhillip>7z 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [<@listfiles...>] <Commands> a: Add files to archive b: Benchmark d: Delete files from archive e: Extract files from archive (without using directory names) l: List contents of archive t: Test integrity of archive u: Update files to archive x: eXtract files with full paths <Switches> -ai[r[-|0]]{@listfile|!wildcard}: Include archives -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives -bd: Disable percentage indicator -i[r[-|0]]{@listfile|!wildcard}: Include filenames -m{Parameters}: set compression Method -o{Directory}: set Output directory -p{Password}: set Password -r[-|0]: Recurse subdirectories -scs{UTF-8 | WIN | DOS}: set charset for list files -sfx[{name}]: Create SFX archive -si[{name}]: read data from stdin -slt: show technical information for l (List) command -so: write data to stdout -ssc[-]: set sensitive case mode -ssw: compress shared files -t{Type}: Set type of archive -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options -v{Size}[b|k|m|g]: Create volumes -w[{path}]: assign Work directory. Empty path means a temporary directory -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames -y: assume Yes on all queries
这篇关于通过 cmd 命令解压缩文件(7-zip)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!