Installing Chocolatey

Posted Chuck Lu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Installing Chocolatey相关的知识,希望对你有一定的参考价值。

 

旧版本

https://chocolatey.org/install

To install chocolatey now, open an administrative command prompt and paste the text from the box below that applies to the name of your shell and press enter. 

第一步,在cmd里面执行一下命令

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"

 

 

 

 

第二步,在PowerShell中执行

iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))

 

第三步,要在3.0以上的PowerShell中执行以下命令

 iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

 

新版本

https://chocolatey.org/docs/installation

Install with PowerShell.exe  (powershell 6.0无法运行安装命令,所以可以用win10自带的powershell 5.0运行下面的安装命令)

With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

  • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.
  • Now run the following command:  (copy command text)
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))

Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.
Extracting C:\\Users\\clu\\AppData\\Local\\Temp\\chocolatey\\chocInstall\\chocolatey.zip to C:\\Users\\clu\\AppData\\Local\\Temp\\chocolatey\\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting \'Machine\')
Setting ChocolateyInstall to \'C:\\ProgramData\\chocolatey\'
WARNING: It\'s very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to \'C:\\ProgramData\\chocolatey\\lib\'
(i.e. C:\\ProgramData\\chocolatey\\lib\\yourPackageName).
A shim file for the command line goes to \'C:\\ProgramData\\chocolatey\\bin\'
and points to an executable in \'C:\\ProgramData\\chocolatey\\lib\\yourPackageName\'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
\'Batch file could not be found\' is also safe to ignore.
\'The system cannot find the file specified\' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
\'C:\\Users\\clu\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

 

以上是关于Installing Chocolatey的主要内容,如果未能解决你的问题,请参考以下文章

记一次Chocolatey造成的开发环境失误

如何在 Chocolatey 安装后刷新 PowerShell 会话的环境而无需打开新会话

window 包管理器--Chocolatey

Chocolatey安装与使用

Windows Chocolatey

Windows包管理工具-Chocolatey