How to change default chocolatey install directory using cmd only?
Asked Answered
A

1

8

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?

Amber answered 26/6, 2017 at 7:22 Comment(0)
S
3

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.

Shamblin answered 26/6, 2017 at 15:58 Comment(4)
Hi, I try to set ChocolateyInstall before i install chocolatey, but i have to close cmd and re-open it to make chocolatey installed in D:\chocolatey (if i don't close cmd and re-open, chocolatey is still installed in default directory C:\ProgramData\chocolatey). Do you know any command to close and open a new cmd ?Kiosk
Choco comes with refreshenv, which will refresh the environment variables without closing cmd - but you need to have choco installed first.Shamblin
I added some additional notes to the answer.Shamblin
It's really helpful, thank you. I found out that when i use only setx ChocolateyInstall D:\Chocolatey i have to close and re-open cmd, but when i use setx ChocolateyInstall D:\Chocolatey /M && SET "ChocolateyInstall=D:\Chocolatey" i don't need to do that.Kiosk

© 2022 - 2024 — McMap. All rights reserved.