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?
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?
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.
choco install libreoffice-fresh -ia "INSTALLDIR=""D:\Program Files\LibreOffice"""
(from that page, just with D:, run in cmd.exe) => The install of libreoffice-fresh was successful. Software installed to 'C:\Program Files\LibreOffice\'
. And while I understand the reason for the paid versions, it's hard to justify buying it without being able to test it properly. Even your codebase uses TARGETDIR ;) –
Insomnia msiexec
either (probably should have tried that earlier, would have saved me a lot of headaches, it works fine with another package). Anyway, I'm wondering if/how the ubiquitous switch deals with that? –
Insomnia For the free version you have to pass the directory as an addtional input argument:
choco install theapp -y --ia "folder switch"
tools\chocolateyInstall.ps1
. If there is no such file go back to search and use the ".installer" version.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 "..."
fileType = msi
: use --ia INSTALLDIR="C:\new\path"
(I did not test this)Do a non-silent installation and specify the path in the ui: choco install theapp --notsilent
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
(I cannot comment directly because of my score, sorry)
--notsilent
flag. Is there a way to set that to be used by default so I don't have to remember to use it every time? –
Despinadespise 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.
mklink /J "C:/ProgramData/chocolatey" D:/my/new/location
(note the added quotation marks). My second directory needed them anyway, so I don't know whether it'll always want them there. Hope it helps someone. –
Univocal 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.
set
in console and see all other things. –
Hinshelwood choco.exe
, you'd still need to write whole path, just because OS does not care about Choco's special env-variable. But, the OS looks into PATH. Adding Choco's path to PATH allows you to write just choco
. And that's pretty much all to it. –
Hinshelwood Use the ChocolateyToolsLocation
environment variable.
The program itself stays where it’s supposed to be, but all installations with choco are installed at D:\tools
.
Or another env-var:
ChocolateyInstall
:D:\ProgramData\chocolatey
Source:
--force
if you are retrying to reinstall an already-installed package to a new location. –
Lucre 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.
--%
switch does? I don't seem to be able to find documentation on that. –
Insomnia --%
before -ia
to just pass the args through as is, which means it should not require any special workarounds." –
Aran C:
drive. Choco 0.10.15
–
Nuclei --ia
option is documented with two dashes –
Nuclei 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.
Adding to @antonio's answer I wanted to put my findings on other cases for setting the installation directory.
For fileType = 'exe'
there seem to be two types of installers which you can tell apart with the given silentArgs
(also in the chocolateyInstall.ps1
).
So far I found /S
as silentArgs and some longer stuff starting with /VERYSILENT /NORESTART
(which seems to be an InnoSetup installer).
/S
: After testing I found this to be working (7zip as example):choco install 7zip.install -y --ia "/D\=D:\Destination\"
(Note: This also triggers debugging output. If you have a solution that doesn't, please tell me!)/VERYSILENT /NORESTART ...
: According to the InnoSetup Installer CLI docs the switch should be /DIR=<path>
and it seems to work like this: choco install pdftk --ia="/DIR=D:\\Tool\\PDFTk"
.A lot of installers also don't use any of the above. VirtualBox for example expects certain installation arguments, the jdk8 package has params to set a directory that way etc. If you cannot match the silentArgs
and fileType
with the above you will have to do a little research.
For VirtualBox I ran the installer with /?
and got a popup explaining the parameters that could be added.
For Mozilla Firefox I found a community post that explained what flags and switches were allowed for the installer. Unfortunately you have to resupply the ini file for updates every time making it a bit tedious.
Now if you primarily use chocolatey to easily update your applications automatically and install them without manually looking for download links and cluttering your download folder with .msi, .exe and .zip files, you can simply add the chocolatey flag --notsilent
(or --not-silent
) to have the installer run normally with all the options you could normally provide to the UI as well. In most cases they are then also used for updates.
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."
© 2022 - 2024 — McMap. All rights reserved.