如何仅使用cmd更改默认的chocolatey安装目录?

时间:2017-06-26 07:22:34

标签: cmd chocolatey

我已按照以下步骤

D:\Chocolatey目录中安装了Chocolatey

https://github.com/chocolatey/choco/wiki/Installation#installing-to-a-different-location

可行,但我必须更改环境变量ChocolateyInstall并手动创建文件夹D:\Chocolatey

有没有办法只使用cmd在非默认目录中安装Chocolatey?

1 个答案:

答案 0 :(得分:2)

从命令行

设置环境变量
  • cmd.exe:setx ChocolateyInstall D:\Chocolatey /M
  • powershell.exe:& setx.exe ChocolateyInstall D:\Chocolatey /M

For Chocolatey

  • cmd.exe:setx ChocolateyInstall D:\Chocolatey /M && SET "ChocolateyInstall=D:\Chocolatey" && "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

您只需尝试SET "ChocolateyInstall=D:\Chocolatey",看看它是否适用于安装。