windows:安装choco(Chocolatey)

一,以管理员身份启动终端:

image

二,安装choco:

使脚本可执行:

PS C:\Users\china> Set-ExecutionPolicy Bypass -Scope Process -Force

安装:

PS C:\Users\china>  powershell -c "irm https://community.chocolatey.org/install.ps1|iex"

三,测试效果:

如果找不到新安装的choco命令,则执行以下命令刷新:

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

如下:

PS C:\Users\china> choco --version
choco : 无法将“choco”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正
确,然后再试一次。
所在位置 行:1 字符: 1
+ choco --version
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\china> $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
PS C:\Users\china> choco --version
2.7.4
PS C:\Users\china>

 

posted @ 2026-09-13 15:31  刘宏缔的架构森林  阅读(15)  评论(0)    收藏  举报