Search code examples
cmdchocolatey

How to change default chocolatey install directory using cmd only?


I've installed Chocolatey in D:\Chocolatey directory by following steps

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

It works, but i have to change environment variable ChocolateyInstall and create the folder D:\Chocolatey manually.

Is there any way do installed Chocolatey in a non-default directory just using cmd?


Solution

  • Set an environment variable from command line

    • 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"

    You could simply try just SET "ChocolateyInstall=D:\Chocolatey" and see if that works for the installation.