问题描述
我按照网站 (https://chocolatey.org/install) 上的说明安装了 Chocolatey.
I installed Chocolatey as per the instructions on the website (https://chocolatey.org/install).
'choco' 命令在 cmd 上正常运行时工作正常,但以管理员身份运行时返回以下错误:
The 'choco' command works fine when I run it normally on cmd but returns the following error when run as administrator:
C:\WINDOWS\system32>choco install -y wget 7zip.commandline
'choco' is not recognized as an internal or external command,
operable program or batch file.
如果不是以管理员身份运行,安装 choco install -y wget 7zip.commandline
会失败.
The install choco install -y wget 7zip.commandline
fails if not run as administrator.
如何修复管理 cmd 中的无法识别"错误?
How do I fix 'not recognized' error in admin cmd?
推荐答案
- 首先,确保您使用的是命令提示符的管理 shell(https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/).
将以下文本复制到命令提示符中.
- First, ensure that you are using an administrative shell of command prompt(https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/).
Copy the below text into the command prompt.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
然后按键盘上的回车键.几秒钟后,您将获得有关当前安装的完整信息.
Then press enter key from the keyboard. After few seconds you get complete info about current installation.
如果您没有看到任何错误.现在输入 choco
或 choco -?
.
If you don't see any errors. Type choco
or choco -?
now.
这篇关于在 Windows 上以管理员身份运行时无法识别“choco"命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!