Chocolatey——像程序员一样安装软件
有一天,你发现了有人推荐了一个解压缩软件,名字叫Bandizip,你想要下载它,你的第一反应是不是先到Bandizip的官方网站下载Bandizip?或是在安全软件附带的应用商店下载?
这个下载方式确实是对的,但是我们可能会想要装逼宣传自己的技术,这时我们可以使用Chocolatey这个包管理器
安装Chocolatey
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'))
在Powershell执行上面的指令,如果报错检查一下有没有管理员权限
等待执行完成
安装完成
在安装完成后,我们在Powershell输入以下内容
choco -v
这用于检测choco的版本
用choco安装软件
现在让我们安装SublimeText3试一下
choco install sublimetext3
如果提示拒绝访问那就把提示的文件夹的权限全部给自己开满,一般在C:/ProgarmData/chocolatey/目录下,如果是其他问题就重启系统
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS C:\Windows\system32> choco install sublimetext3
Chocolatey v2.3.0
Installing the following packages:
sublimetext3
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading SublimeText3 3.2.2... 100%
sublimetext3 v3.2.2 [Approved]
sublimetext3 package files install completed. Performing other installation steps.
The package sublimetext3 wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A
Using system proxy server '127.0.0.1:7890'.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Hashes match.
Hashes match.
Installing SublimeText3...
SublimeText3 has been installed.
sublimetext3 can be automatically uninstalled.
The install of sublimetext3 was successful.
Deployed to 'C:\Program Files\Sublime Text 3\'
Chocolatey installed 1/1 packages.
See the log for details (D:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32>
这时就可以使用Sublime Text3了
卸载用choco安装的软件
和安装(install)相反,卸载是用的uninstall
choco unistall sublimetext3
输出结果:
PS C:\Windows\system32> choco uninstall sublimetext3
Chocolatey v2.3.0
Uninstalling the following packages:
sublimetext3
sublimetext3 v3.2.2
The package sublimetext3 wants to run 'chocolateyUninstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A
Uninstalling sublimetext3...
0
sublimetext3 has been uninstalled.
Running auto uninstaller...
Skipping auto uninstaller - 'Sublime Text 3' appears to have been uninstalled already by other means.
sublimetext3 has been successfully uninstalled.
Chocolatey uninstalled 1/1 packages.
See the log for details (D:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32>
这时Sublimetext3已经消失不见了
Chocolatey——像程序员一样安装软件
https://zhiyuhub.top/archives/chocolatey