[英]'PowerShell' is not recognized as an internal or external command
I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error: 我刚刚通过PowerShell安装了Chocolatey,我尝试以自己和管理员身份运行PowerShell,如果我尝试运行choco或cinst,我会收到以下错误:
PS C:\> choco /?
'PowerShell' is not recognized as an internal or external command,
operable program or batch file.
What do I do? 我该怎么办? I have a feeling this is related to more than just Chocolatey... 我觉得这不仅仅与Chocolatey有关......
This can happen if a program is not on your PATH. 如果程序不在您的PATH上,则会发生这种情况。 Open a PowerShell prompt and enter 打开PowerShell提示并输入
[environment]::setEnvironmentVariable('PATH',
"$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm')
then restart PowerShell. 然后重新启动PowerShell。
I found this helpful. 我觉得这很有帮助。
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(' https://chocolatey.org/install.ps1 '))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin @powershell -NoProfile -ExecutionPolicy Bypass -Command“iex((new-object net.webclient).DownloadString(' https://chocolatey.org/install.ps1 '))”&& SET PATH =%PATH%;%ALLUSERSPROFILE% \\的巧克力\\斌
Put Chocolatey on the path. 把Chocolatey放在路上。
Edit the system environmental variable. 编辑系统环境变量。 Go to 去
System Properties → Advanced → Environment Variables → System variables → PATH → Edit → New 系统属性 → 高级 → 环境变量 → 系统变量 → 路径 → 编辑 → 新建
Look for where Chocolatey is. 寻找Chocolatey的位置。 In my case it was at C:\\ProgramData\\chocolatey
. 就我而言,它位于C:\\ProgramData\\chocolatey
。 Enter that, don't forget to put "\\" after Chocolatey. 输入,不要忘记在Chocolatey之后加上“\\”。 Ie, it should be: C:\\ProgramData\\chocolatey\\
即,它应该是: C:\\ProgramData\\chocolatey\\
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.