- https://chocolatey.org/
- https://chocolatey.org/packages
- https://chocolatey.org/docs/commands-reference#how-to-pass-options—switches
- https://chocolatey.org/docs/commands-install#examples
安装Chocolate
安装Chocolate,在PowerShell中执行:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
或者直接运行以下命令:
@"%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"
执行choco查看版本:
$ choco
Chocolatey v0.10.15
Please run 'choco -?' or 'choco <command> -?' for help menu.
使用以下命令查看帮助:
choco -h # 查看帮助
choco <command> -h #查看相应命令的帮助
Chocolatey常用命令
search
搜索包choco search <package name>
install
安装choco install <package name>
uninstall
安装包的卸载choco uninstall <package name>
upgrade
安装包的升级choco upgrade <package name>
pin
固定包的版本,防止包被升级choco pin <package name>
list
列出包choco list -lo
安装软件包
注意:使用choco安装软件需要以管理员权限运行powershell
使用install命令安装软件, 安装过程如下:
$ choco install git
Chocolatey v0.10.15
Installing the following packages:
git.install
git.install v2.26.2 already installed. Forcing reinstall of version '2.26.2'.
Please use upgrade if you meant to upgrade to a new version.
[NuGet] Uninstalling 'git.install 2.26.2' might cause 'git 2.26.2' to be broken.
git.install v2.26.2 (forced) [Approved]
git.install package files install completed. Performing other installation steps.
The package git.install wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y
Using Git LFS
Installing 64-bit git.install...
git.install has been installed.
git.install installed to 'C:\Program Files\Git'
git.install can be automatically uninstalled.
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The install of git.install was successful.
Software installed to 'C:\Program Files\Git\'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Enjoy using Chocolatey? Explore more amazing features to take your
experience to the next level at
https://chocolatey.org/compare
安装常用软件包
choco install git
choco install nodejs
choco install mysql
choco install maven
choco install jdk7
choco install jdk8
choco install python
choco install ruby
choco install erlang
choco install dart-sdk
choco install typora
choco install googlechrome
choco install google-chrome-x64
choco install firefox
choco install autohotkey.portable
choco install notepadplusplus.install
choco install Atom
choco install SublimeText3
choco install compass -source ruby # 安装Ruby Gem
choco install sphynx -source python # 安装Python Egg
choco install IIS -source windowsfeatures # 安装IIS服务器特性
choco install IIS7.5Express -source webpi # 安装Webpi特性
使用-y
参数可以静默安装而不需要用户确认:
choco install git -y
修改软件包安装路径
使用以下参数可以修改软件包安装路径:
--install-args="'/DIR=value'"
比如:
choco install 1password --install-args="'/DIR=D:\Software\1password'" -y
安装指定的软件包版本
使用 --version
参数可以指定软件包的版本:
choco install ruby --version 2.1.5 -y
使用 -m
参数允许安装相同软件包的多个版本:
choco install ruby --version 2.1.5 -my
软件包列表
查看本地安装的软件包
choco list -lo
choco list --local-only
列出Windows系统已安装的软件
choco list -li OR choco list -lai
升级软件包
升级所有已安装软件包
choco upgrade all -y
升级指定的软件包
choco upgrade maven