在 Windows 上以管理员身份运行时无法识别“choco"命令

编程入门 行业动态 更新时间:2024-10-22 16:34:42
本文介绍了在 Windows 上以管理员身份运行时无法识别“choco"命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我按照网站 (https://chocolatey/install) 上的说明安装了 Chocolatey.

I installed Chocolatey as per the instructions on the website (https://chocolatey/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 7zipmandline
'choco' is not recognized as an internal or external command,
operable program or batch file.

如果不是以管理员身份运行,安装 choco install -y wget 7zipmandline 会失败.

The install choco install -y wget 7zipmandline fails if not run as administrator.

如何修复管理 cmd 中的无法识别"错误?

How do I fix 'not recognized' error in admin cmd?

推荐答案

首先,确保您使用的是命令提示符的管理 shell(https://www.howtogeek/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/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/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.

如果您没有看到任何错误.现在输入 chocochoco -?.

If you don't see any errors. Type choco or choco -? now.

参考

这篇关于在 Windows 上以管理员身份运行时无法识别“choco"命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 22:53:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125484.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上以   命令   管理员   身份   无法识别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!