![chocolatey 安装](https://i-blog.csdnimg.cn/blog_migrate/bb791336fdb6073504851510a605eb01.png)
chocolatey 安装
Linux distributions have different package managers like apt, yum, dnf in order to install applications, programs, packages. Windows recently has a package manager named Chocolatey
which can search, install, remove Windows packages from a decentralized repository. It uses the NuGet infrastructure using PowerShell.
Linux发行版具有不同的软件包管理器,如apt,yum,dnf,以便安装应用程序,程序,软件包。 Windows最近有一个名为Chocolatey
的程序包管理器,可以从分散的存储库中搜索,安装或删除Windows程序包。 它使用通过PowerShell使用的NuGet基础结构。
巧克力味 (Chocolatey Features)
Chocolatey provides advanced features like below.
Chocolatey提供了如下高级功能。
- Chocolatey provides an unattended installation with a PowerShell. Chocolatey使用PowerShell提供了无人参与的安装。
- Chocolatey works all existing software installation technologies like MSI, NSIS, InnoSeyup, etc. Chocolatey使用所有现有的软件安装技术,例如MSI,NSIS,InnoSeyup等。
- Chocolatey can manage all aspects of software like search, install, update, remove. Chocolatey可以管理软件的所有方面,例如搜索,安装,更新和删除。
- With PowerShell, software management can be automated by supporting complex scenarios. 使用PowerShell,可以通过支持复杂方案来实现软件管理的自动化。
- Easily build software installation packages. 轻松构建软件安装包。
- With Packet Internalizer makes offline package installation. 使用Packet Internalizer可以进行脱机软件包安装。
- Chocolatey integrates with configuration managers like SCCM, Puppet, Chef, or PowerShell DSC. Chocolatey与SCCM,Puppet,Chef或PowerShell DSC等配置管理器集成。
- Create an internal organization repository for application installation. 创建用于组织应用程序安装的内部组织存储库。
- Provides CLI tool named, choco.exe for command-line usage. 提供名为choco.exe的CLI工具以供命令行使用。
- Provide a GUI tool named Chocolatey GUI for human-friendly usage. 提供一个名为Chocolatey GUI的GUI工具,以方便人类使用。
Chocolatey安装要求 (Chocolatey Installation Requirements)
Chocolatey can be used with PowerShell and .Net Framework there is the following requirements in order to use Chocolatey.
Chocolatey可以与PowerShell和.Net Framework一起使用,要使用Chocolatey,需要满足以下要求。
- Windows 7+/Windows 2003+ (Server Core also, but not Windows Nano Server) Windows 7 + / Windows 2003+(也是服务器核心,但不是Windows Nano Server)
- Windows PowerShell v2+ (not PowerShell Core aka PowerShell 6 yet) Windows PowerShell v2 +(还不是PowerShell Core aka PowerShell 6)
- .NET Framework 4.x+ .NET Framework 4.x以上
使用MS-DOS命令行在Windows上安装Chocolatey(Install Chocolatey On Windows with MS-DOS Command-line)
We can install Chocolatey
from the MS-DOS command line. First, we will open the MS-DOS command line with Administrative privileges below. Click open Start Menu
and write cmd
which will list Command Prompt
. Right-click to the Command prompt which will open a menu which contains Run as administrator
like below and click to open it.
我们可以从MS-DOS命令行安装Chocolatey
。 首先,我们将在下面使用管理权限打开MS-DOS命令行。 单击打开的Start Menu
然后输入cmd
,其中将列出Command Prompt
。 右键单击“命令”提示符,将打开一个菜单,其中包含如下所示的Run as administrator
,然后单击以将其打开。
![](https://i-blog.csdnimg.cn/blog_migrate/9b9c18a4a2cb050530241f5e2a3d53cd.png)
Then there will be a User Account Control. We will click to Yes
然后将有一个用户帐户控件。 我们将单击“ Yes
![User Account Control](https://i-blog.csdnimg.cn/blog_migrate/eefaf14b95dc1372c35c95299caafb8f.png)
We will use the following command which is a bit complex but do not worry it will work seamlessly.
我们将使用以下命令,该命令有点复杂,但是请不要担心它将无缝运行。
> @"%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"
![Install Chocolatey On Windows with MS-DOS Command-line](https://i-blog.csdnimg.cn/blog_migrate/161c45b6f6354ce3518e828ee537995f.png)
使用PowerShell命令行在Windows上安装Chocolatey (Install Chocolatey On Windows with PowerShell Command-line)
We can install Chocolatey
from the PowerShell command line. First, we will open the PowerShell command line with Administrative privileges below. Click open Start Menu and write cmd which will list Command Prompt. Right-click to the Command prompt which will open a menu which contains Run as administrator
like below and click to open it.
我们可以从PowerShell命令行安装Chocolatey
。 首先,我们将在下面使用管理权限打开PowerShell命令行。 单击打开的开始菜单,然后输入cmd,其中将列出命令提示符。 右键单击“命令”提示符,将打开一个菜单,其中包含如下所示的Run as administrator
,然后单击以将其打开。
![](https://i-blog.csdnimg.cn/blog_migrate/cb3e7e65c626eb2be8e8b802afa553d6.png)
Then there will be a User Account Control. We will click to Yes
然后将有一个用户帐户控件。 我们将单击“ Yes
![](https://i-blog.csdnimg.cn/blog_migrate/0776d33986a030750d3fa1e6a1c9b0d0.png)
We will use the following command which is a bit complex but does not worry it will work seamlessly. Then we will enable the unsigned PowerShell scripts to run on PowerShell. We will use Set-ExecutionPolicy
. There will be a prompt where we will accept with A
.
我们将使用以下命令,该命令有点复杂,但是请不要担心它将无缝运行。 然后,我们将使未签名的PowerShell脚本能够在PowerShell上运行。 我们将使用Set-ExecutionPolicy
。 我们将接受A
的提示。
PS> Set-ExecutionPolicy AllSigned
![](https://i-blog.csdnimg.cn/blog_migrate/3b9689e1f36ed894c62d123afdc2eb60.png)
Now we can run the PowerShell installation script like below.
现在,我们可以运行如下所示的PowerShell安装脚本。
PS> Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
![](https://i-blog.csdnimg.cn/blog_migrate/c7d927f1dea584949c075b18989fd8d7.png)
打印朱古力版 (Print Chocolatey Version)
After installing the Chocolatey
we will print the version we have installed. We will use -v
option which will print only the version of choco.exe
.
安装Chocolatey
之后,我们将打印已安装的版本。 我们将使用-v
选项,该选项将仅打印choco.exe
的版本。
PS> choco.exe -v
![Print Chocolatey Version](https://i-blog.csdnimg.cn/blog_migrate/8c5ee355040b0245efd8f0915f754eb1.png)
打印Chocolatey帮助信息(Print Chocolatey Help Information)
We can print help information about the choco.exe
with the -h
option. This will simply print general commands and detailed usage information about the choco.exe
.
我们可以使用-h
选项打印有关choco.exe
帮助信息。 这将仅打印有关choco.exe
常规命令和详细的使用信息。
PS> choco.exe -h
![Print Chocolatey Help Information](https://i-blog.csdnimg.cn/blog_migrate/00c935ed00bcf41e9a2548f8ea3201cb.png)
用Chocolatey搜索软件包,程序(Search Packages, Programs with Chocolatey)
We will start with a searching specific package with the search
command. In this example, we will search for the package named winamp
.
我们将从使用search
命令搜索特定软件包开始。 在此示例中,我们将搜索名为winamp
的软件包。
PS> choco.exe search winamp
![Search Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/c229bd5780d3d833fe4b746c01092f7e.png)
We can see that related packages are listed with the following information. We can see that there are 9 results which matched with the term winamp
.
我们可以看到相关软件包列出了以下信息。 我们可以看到有9个结果与术语winamp
相匹配。
package name
is the exact name of the package likewinamp
.package name
是package name
的确切名称,例如winamp
。version
is the latest package version which is5.666
.version
是最新的软件包版本5.666
。package status
is the state of the package whether it is approved or not.package status
是package status
的状态,无论是否已批准。
打印有关Chocolatey软件包,程序的信息(Print Information About Packages, Programs with Chocolatey)
Before installation or if we are curious we can list detailed information about a package. We will use info
command by providing the exact name of the package which is winamp
in this example.
在安装之前,或者如果我们好奇,我们可以列出有关软件包的详细信息。 在此示例中,我们将通过提供软件包的确切名称(即winamp
来使用info
命令。
PS> choco.exe info winamp
![Print Information About Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/c2c5e6976f7433a54d0d124cf575b8b2.png)
We can see that there is detailed information about the package like below.
我们可以看到有关该软件包的详细信息,如下所示。
Title
is the official name of the package which isWinamp
.Title
是软件包的正式名称,即Winamp
。Published
is the date the package last time published.Published
是包上次Published
的日期。Package Testing Status
is the package test result and status whether it is working properly.Package Testing Status
是包装测试结果和状态(是否正常工作)。Number of Download
is the total download number.Number of Download
是总下载数。Downloads for this version
is the download number for the listed version which is 3386.Downloads for this version
的下载是列出的版本的下载号3386。Package URL Chocolatey Package Source
is the source of the package URL location.Package URL Chocolatey Package Source
是软件包URL位置的源。Package Checksum
is the SHA512 package hash.Package Checksum
是SHA512软件包的哈希值。Tags
are keywords describing the package like category.Tags
是描述类包装的关键字。Software site
is the site of the publishing of the software.Software site
是Software site
发布的站点。Software License
Software License
Summary
is very little description of the package.Summary
是对软件包的很少描述。Description
is detailed information about the package.Description
是有关包装的详细信息。
用Chocolatey安装软件包,程序 (Install Packages, Programs with Chocolatey)
We can install specific a package with the install
command by providing the package name.
通过提供软件包名称,我们可以使用install
命令安装特定的软件包。
PS> choco.exe install winamp
![Install Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/5f67e5ca1b504a2c5997440c99983542.png)
We can see that Winamp installation is completed successfully after following steps.
在执行以下步骤后,我们可以看到Winamp安装成功完成。
- The license is accepted 许可证被接受
- Package is downloaded包已下载
- Accept to run installation scripts接受运行安装脚本
- Installation Result安装结果
使用Chocolatey安装多个软件包,程序(Install Multiple Packages, Programs with Chocolatey)
We can also install multiple packages or programs with a single install command by separating them with spaces. We will use install
command in order to install nmap, notepadplusplus and winamp like below.
我们也可以使用一个安装命令来安装多个软件包或程序,方法是用空格分隔它们。 我们将使用install
命令来安装nmap,notepadplusplus和winamp,如下所示。
PS> choco.exe install notepadplusplus nmap winamp
![Install Multiple Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/baa49fa3e0810bd940b26e0afaab7eec.png)
用Chocolatey更新指定的程序包,程序(Update Specified Packages, Programs with Chocolatey)
We can update specific packages with the upgrade
command. We will also specify the package named which is nmap
in this case.
我们可以使用upgrade
命令更新特定的软件包。 在这种情况下,我们还将指定名为nmap
的软件包。
PS> choco.exe upgrade nmap
![Update Specified Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/9baccbc441864302ba9818aa350945d7.png)
用Chocolatey列出过期/旧包装(List Outdated/Old Packages with Chocolatey)
We can also list currently installed and outdated or old packages. We will use outdated
command like below.
我们还可以列出当前已安装和已过期或旧的软件包。 我们将使用如下所示的outdated
命令。
PS> choco.exe outdated
![List Outdated/Old Packages with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/9c2cb123fb9f887ab4d5a9c5bd5e1cd4.png)
While listing outdated packages the following information is provided.
在列出过时的软件包时,将提供以下信息。
Package name
Package name
Current version
is the currently installed an outdated version.Current version
是当前安装的过时版本。Available Version
is the updated version available.Available Version
是Available Version
的更新版本。Pinned
Pinned
用Chocolatey删除/卸载软件包,程序 (Remove/Uninstall Packages, Programs with Chocolatey)
We can remove or uninstall the specified package. We will use uninstall
command like below. We will uninstall the package named uninstall
.
我们可以删除或卸载指定的软件包。 我们将使用如下所示的uninstall
命令。 我们将卸载名为uninstall
的软件包。
PS> choco.exe uninstall winamp
![Remove/Uninstall Packages, Programs with Chocolatey](https://i-blog.csdnimg.cn/blog_migrate/65f905856ece7bf1e7d8ac27a2ff72a5.png)
自己更新/升级Chocolatey(Update/Upgrade Chocolatey Itself)
Chocolatey is updated regularly. We can update upgrade chocolatey with the following command.
Chocolatey会定期更新。 我们可以使用以下命令更新升级Chocolatey。
PS> choco.exe install chocolatey
在Windows上安装Chocolatey GUI (Install Chocolatey GUI onWindows)
Chocolatey GUI is provided with the choco.exe
we will install it with the package named chocolateygui
.
Chocolatey GUI随choco.exe
一起提供,我们将使用名为chocolateygui
的软件包进行安装。
PS> choco.exe install chocolateygui
![Install Chocolatey GUI onWindows](https://i-blog.csdnimg.cn/blog_migrate/d319147f72f8d34bb37902b7984d5bad.png)
Chocolatey GUI (Chocolatey GUI)
We can open Chocolatey GUI from the Start menu like below.
我们可以从“开始”菜单中打开Chocolatey GUI,如下所示。
![Open Chocolatey GUI](https://i-blog.csdnimg.cn/blog_migrate/be7d29f71607ab87efdf83c3d1c3a8ab.png)
As this is a package manager to install packages we required Administrative privileges
由于这是安装软件包的软件包管理器,因此我们需要管理权限
![](https://i-blog.csdnimg.cn/blog_migrate/0bf074ee3ec4c19c1fe222181d4b10b5.png)
We will see the following dashboard which will provide most of the command line functions like install, update, remove.
我们将看到以下仪表板,它将提供大多数命令行功能,例如安装,更新,删除。
![Chocolatey GUI](https://i-blog.csdnimg.cn/blog_migrate/7f9b33775fe098d6df4e10915b9deaf5.png)
翻译自: https://www.poftut.com/how-to-install-and-use-chocolatey-package-manager-for-windows/
chocolatey 安装