2022-10-11 15:36:51 +08:00
|
|
|
|
# Chocolatey 的安装和使用
|
|
|
|
|
|
|
|
|
|
Chocolatey 是一款命令行下的 Windows 软件包管理工具。
|
|
|
|
|
|
|
|
|
|
## 1. 安装
|
|
|
|
|
|
|
|
|
|
### 1.1. 安装前的准备
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 查看 Get-ExecutionPolicy 是否受限制
|
|
|
|
|
Get-ExecutionPolicy
|
|
|
|
|
## 如果它返回 Restricted,则运行下面的语句(3 选 1 即可)
|
|
|
|
|
|
|
|
|
|
# 信任脚本执行策略
|
|
|
|
|
set-ExecutionPolicy RemoteSigned -Force
|
|
|
|
|
# 或
|
|
|
|
|
# 设为 AllSigned 策略提高安全性
|
|
|
|
|
Set-ExecutionPolicy AllSigned
|
|
|
|
|
# 或
|
|
|
|
|
# 设置 Bypass 策略
|
|
|
|
|
Set-ExecutionPolicy Bypass -Scope Process
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 1.2. Powershell 2+ 安装 Choco
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 以管理员运行powershell 2+
|
|
|
|
|
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 2. Choco 常见操作
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# choco 版本查看
|
|
|
|
|
choco -v
|
|
|
|
|
# choco 版本更新
|
|
|
|
|
choco upgrade chocolatey
|
|
|
|
|
|
|
|
|
|
#查看 Chocolatey 安装的装所有程序的列表
|
|
|
|
|
choco list --local
|
|
|
|
|
# 查看本地安装的软件
|
|
|
|
|
choco list -li
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 安装
|
|
|
|
|
choco install 软件包名
|
|
|
|
|
|
|
|
|
|
# 搜索软件
|
|
|
|
|
choco search 软件包名
|
|
|
|
|
|
|
|
|
|
# 查看软件包详情
|
|
|
|
|
choco info 软件包名
|
|
|
|
|
|
|
|
|
|
# 卸载
|
|
|
|
|
choco uninstall 软件包名
|
|
|
|
|
|
|
|
|
|
# 查看需要更新的软件列表
|
|
|
|
|
choco outdated
|
|
|
|
|
|
|
|
|
|
# 更新指定软件包
|
|
|
|
|
choco upgrade 软件包名 -y
|
|
|
|
|
|
|
|
|
|
# 更新所有软件
|
|
|
|
|
choco upgrade all -y
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2.1. choco 清理工具(必装)
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 安装清理工具
|
|
|
|
|
choco install choco-cleaner -y
|
|
|
|
|
# 执行清理
|
|
|
|
|
choco-cleaner
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2.2. 包下载目录
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 下载的包源码目录
|
|
|
|
|
C:\Users\username\AppData\Local\Temp\
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2.3. 常见的命令行工具安装目录
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
C:\ProgramData\chocolatey\lib
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-12 15:33:04 +08:00
|
|
|
|
## 3. 外部参考资料
|
2022-10-11 15:36:51 +08:00
|
|
|
|
|
2022-12-12 15:33:04 +08:00
|
|
|
|
1. [Installing Chocolatey](https://chocolatey.org/install)
|
|
|
|
|
2. [Windows 使用 choco 包管理器](https://blog.csdn.net/omaidb/article/details/120028664)
|
|
|
|
|
3. [Win10 离线安装 choco 方案](https://blog.csdn.net/omaidb/article/details/126669503)
|