How do I set Chocolatey to install applications onto another drive?

I've installed Chocolatey, but I would like it to install programs to another drive instead of C. C is only a small SSD, but I have other drives where I usually install programs to.

Any ideas?


Solution 1:

Chocolatey FOSS

For each application, you would need to know its command line switch used during installation to change its installation directory and pass it using --installArgs. See Install Command (choco install) and Overriding default install directory or other advanced install concepts.

Another way to ensure a different drive is to relocate your Program Files to a different drive. You may want to look that up; it is possible to do.

Chocolatey Licensed Versions

We've added the ubiquitous install switch! If you need to override the install directory and you don't want to do all of the work to determine what that switch is, you have the option to use one switch with Chocolatey - Ubiquitous Install Directory Option (Licensed Editions Only).

NOTE: We need to ensure the longevity of the Chocolatey community somehow, and that is to have a FOSSium (freemium) model. The Pro version is $8/month (annually $96), costs you less than eating out once a month, gets you some awesome features, and ensures that the community infrastructure continues to provide a great service and improve. While you are using a free service (the community repository, aka https://chocolatey.org/packages), it is not free to provide that service. So we select certain premium features to go into those versions to provide enough value to be worth the price.

Solution 2:

I've found another simple trick - install choco as usual, and right after installation move the c:\programdata\chocolatey directory anywhere you like, and then update ChocolateyInstall environment variable and also update PATH environment variable so choco's \bin subfolder is found after moving it.

Of course, I don't know if it fine with any other packages, but I just installed 7zip and docker-machine with no problems, so seems to work.

Solution 3:

You could move the Chocolatey directory to another location then create a hard symbolic link from the default location - see The Complete Guide to Creating Symbolic Links (AKA Symlinks) on Windows.

I.e. mklink /J C:/ProgramData/chocolatey D:/my/new/location

But be sure to create the usual backups, restore points, etc. before doing anything.

Solution 4:

For an MSI package (which is most often the case in Windows) use:

choco install package-name  --% -ia INSTALLDIR="c:\intall\path"

To see whether the package is an MSI one, on the Chocolatey package page, under Files, look for chocolateyInstall.ps1 and then look for:

fileType = 'msi'

It was tested with Strawberry Perl.

Of course, you can always use the paid chocolate and benefit from the ubiquitous install switch.

Solution 5:

Summarized and corrected solution (incl. convenience script)

For the free version you have to pass the directory as an addtional input argument:

choco install theapp -y --ia "folder switch"


The challenge is that the switch differs from installer to installer.

Proceeding to determine the installer

  1. Go to the chocolatey package repo and search for your app
  2. Scroll down to "List Files" and open tools\chocolateyInstall.ps1. If there is no such file go back to search and use the ".installer" version.
  3. Search for fileType = exe. Most of my tested apps had this extension. If it's the case search for silentArgs. If there is a:
  • /S: use --ia "/D=C:\new\path. Note: single backslashes, double backslashes didn't work for me. Also no backslash before the = sign, as suggested in other comments.
  • /VERYSILENT: use --ia /DIR=C:\new\path. The verysilent switch belongs to the InnoSetup Installer.
  • something else: search "app silent install" on google, determine the path switch and enter it accordingly: --ia "..."
  1. fileType = msi: use --ia INSTALLDIR="C:\new\path" (I did not test this)

Fallback solution

Do a non-silent installment and specify the path in the ui: choco install theapp --notsilent

Convenience script

I created a Powershell script which allows to install common apps (vlc, VS Code, python, git, Chrome...) with custom parameters, incl. folders:

https://github.com/vii33/ChocoVanillaPackage


Remarks to other comments

(I cannot comment directly because of my score, sorry)

  • @geisterfurz007 Thank you for the manual.
  • @quetzalcoatl This did not work for me since applications are not installed inside the chocolatey folder. Your solution moves the chocolatey binaries, the package installation is still done in the default folder.