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 program
The accepted answer hints at this option already, so I'm only posting for the sake of completeness:
While SSDs have gotten bigger and cheaper in recent years, there are still some niche use cases where you want to keep a Windows install on a separate, smaller partition and software on a different, bigger partition.
win + R
and type regedit
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
ProgramFilesDir
and ProgramFilesDir (x64)
from C:\ProgramFiles
to [your drive]:\Program Files
Citing my sources: this answer but longer.
Chocolatey will, in general, respect this — but there's a few caveats with that method that need to be mentioned:
ProgramFilesDir
registry keys. For example, Audacity still installed to C:
(despite — in my case, at least — ProgramFilesDir
is F:\Program Files
, but chocolatey made an assumption that it's installed to F:
when making the shortcuts and start menu entries).ProgramFilesDir
registry keys before installing anything with chocolatey, otherwise some scripts, packages, or programs might be broken (for example, I had to reinstall the chocolateygui
package)Side note: this answer operates under assumption that "how do I set chocolatey to install applications onto another drive" means "how do I set chocolatey to install application to the same drive where I've installed most of my other software."
For the free version you have to pass the directory as an addtional input argument:
choco install theapp -y --ia "folder switch"
Challenge is that the switch differs from installer to installer.
tools\chocolateyInstall.ps1
. If there is no such file go back to search an use the "... .installer" version of the app.Search for fileType = exe
. This was the case for most of my tested apps (see below). 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, gave me also an error. /VERYSILENT
: use --ia /DIR=C:\new\path
. The verysilent switch belongs to the InnoSetup Installer.something else
: google "app silent install", determine the path switch and enter accordingly: --ia "..."
fileType = msi
: use --ia INSTALLDIR="C:\new\path"
(I did not test this)
Do a non-silent installment: choco install theapp --notsilent
I wrote a powershell script which either installs apps in their default location or to a new one (provided by you). Applications are provided as a dictionary containing package-name
as key
and optional input arguments
as value
. Be aware of the single and double quotation marks.
# --------------------------------------------------------------
# If installation should be in specific path, then provide it as value in the Dict / Hash table.
# Additional choco installer switches have to be set after the path.
$packToInstall= @{
notepadplusplus='';
vlc=''; # Install Dir can only be set via registry
irfanview='';
irfanviewplugins='';
teamviewer='/D=D:\Programme\choco\TeamViewer"';
vscode='"/DIR=D:\Programme\choco\vsCode" /NoDesktopIcon /NoQuicklaunchIcon';
'cpu-z.install'='"/DIR=D:\Programme\choco\cpu-z" ';
}
# --------------------------------------------------------------
# -------------- Script Start ----------------------------------
ForEach($key in $packToInstall.Keys){
if ($packToInstall[$key]) {
choco install $key -y --ia $packToInstall[$key]
}
else {
# Default installer
choco install $key -y
}
}
Save as script.ps1 and run as admin. If the execution policies trouble you: PowerShell.exe -ExecutionPolicy UnRestricted -File .\script.ps1
(I cannot comment directly because of my score, sorry)
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.
It looks like Chocolatey has now created a ubiquitous switch:
Ubiquitous Install Directory Option (Licensed Editions Only)
I've not had chance to use this personally, but it looks like this would do the trick. If a little manual per application.
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.
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.
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.