Chocolatey—windows下最好用的包管理器安装使用
Chocolatey是windows下的一种包管理器,它可以让我们体验到在linux系统下安装包一样方便快捷,可以用cmd和powershell安装。安装注意:下面方法都需要管理员权限下进行安装。cmd@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -Execut
·
Chocolatey是windows下的一种包管理器,它可以让我们体验到在linux系统下安装包一样方便快捷,可以用cmd和powershell安装。
安装
注意:下面方法都需要管理员权限下进行安装。
- cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
- PowerShell
这里要先运行下Get-ExecutionPolicy
,如果返回Restricted
,那么需要运行Set-ExecutionPolicy AllSigned
或者Set-ExecutionPolicy Bypass -Scope Process
。
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'))
使用
# 查看版本
choco -V
# 确认
choco -y, --yes, --confirm
# 更多查看帮助菜单的
choco -?, --help, -h
# 安装软件包
choco install package_name
choco install git
# 或者
cinst package_name
# 卸载软件包
choco uninstall package_name
choco uninstall git
# 或者
cuninst package_name
# 升级
choco upgrade package_name
例子
choco install sysinternals
choco install notepadplusplus googlechrome atom 7zip
choco install notepadplusplus --force --force-dependencies
choco install notepadplusplus googlechrome atom 7zip -dvfy
choco install git -y --params="'/GitAndUnixToolsOnPath /NoAutoCrlf'"
choco install git -y --params="'/GitAndUnixToolsOnPath /NoAutoCrlf'" --install-args="'/DIR=C:\git'"
# Params are package parameters, passed to the package
# Install args are installer arguments, appended to the silentArgs
# in the package for the installer itself
choco install nodejs.install --version 0.10.35
choco install git -s "'https://somewhere/out/there'"
choco install git -s "'https://somewhere/protected'" -u user -p pass
代理设置
$env:chocolateyProxyLocation = 'https://local/proxy/server'
#$env:chocolateyProxyUser = 'username'
#$env:chocolateyProxyPassword = 'password'
# install script
# 详情参考 https://chocolatey.org/docs/proxy-settings-for-chocolatey
更多用法直接查看 官方文档.
更多推荐
已为社区贡献2条内容
所有评论(0)