Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default chocolatey install directory using cmd only?

Tags:

cmd

chocolatey

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?

like image 513
Trương Anh Avatar asked Oct 30 '22 06:10

Trương Anh


1 Answers

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.

like image 153
ferventcoder Avatar answered Jan 02 '23 20:01

ferventcoder