管理员身份安装步骤
-
首先,确保您使用的是管理员shell,您也可以以非管理员身份安装,请查看非管理员身份安装
-
使用 powershell.exe 安装
使用 PowerShell,必须确保 Get-ExecutionPolicy 不受限制。我们建议使用 Bypass 绕过策略来安装东西或 AllSigned 提高安全性。
- 运行
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://community.chocolatey.org/install.ps1'))
非管理员身份安装步骤
您必须选择与默认位置不同的位置(请参阅上面的安装到其他位置)。默认设置是只有管理员才能更新的更安全的位置。
- 将下面的脚本另存为
ChocolateyInstallNonAdmin.ps1
# Set directory for installation - Chocolatey does not lock # down the directory if not the default $InstallDir='C:\ProgramData\chocoportable' $env:ChocolateyInstall="$InstallDir" # If your PowerShell Execution policy is restrictive, you may # not be able to get around that. Try setting your session to # Bypass. Set-ExecutionPolicy Bypass -Scope Process -Force; # All install options - offline, proxy, etc at # https://chocolatey.org/install iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- 使用上面的脚本将
Chocolatey
安装在C:\ProgramData\chocoportable
,如果不希望安装在此处,可更改为您想要Chocolatey
安装的位置。 - 打开
PowerShell
,并运行以下命令:Set-ExecutionPolicy Bypass -Scope Process -Force;
- 运行
.\ChocolateyInstallNonAdmin.ps1