Download Choco For Windows

0 views
Skip to first unread message

Dot Liljenquist

unread,
Aug 3, 2024, 6:09:33 PM8/3/24
to acobexem

With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

The command for installing with PowerShell at the top of the page works for all versions of PowerShell from v2 on. This is provided as an additional note for folks who want a more terse command that is easier to remember.

With PowerShell, there is an additional step or two. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

With completely offline use of Chocolatey, you want to ensure you remove the default community package source (choco source list followed by choco source remove --name chocolatey, or however you would do that with a configuration manager like Puppet).

If you prefer to have the install.ps1 file already, comment out the download line in the batch file and download the install.ps1 from community.chocolatey.org and save it as install.ps1 next to the installChocolatey.cmd file.

Run installChocolatey.cmd from an elevated cmd.exe command prompt and it will install the latest version of Chocolatey. You can not run this from powershell.exe without making changes to your execution policy.

When you have Visual Studio 2010+ and the NuGet extension installed (pre-installed on any newer versions of Visual Studio), you can simply type the following three commands and you will have Chocolatey installed on your machine.

This will not set Chocolatey as an installed package, so it may be a good idea to also call choco upgrade chocolatey -y and let it reinstall the same version, but at least it will be available for upgrades then.

There is one really important consideration when installing Chocolatey to a non-default location: Chocolatey only locks down the permissions to Admins when installed to the default location %PROGRAMDATA%\Chocolatey, which means the same thing as %SystemDrive%\ProgramData\Chocolatey.

If you are installing to another location, you will need to handle this yourself, i.e. restrict write access to Admins in case you so desire.This is due to alternative locations could have a range of permissions that should not be changed.See Why does Chocolatey install where it does and GitHub Issue 398 for more details.

If your server is restricted to TLS 1.1+, you need to add additional logic to be able to download and install Chocolatey (this is not necessary when running Chocolatey normally as it does this automatically).

This option should be a last resort and is considered to be a more advanced scenario - most things you do on Windows require administrative rights, especially surrounding software management, so you are going to be limited even in packages you attempt to install. If you are using the community package repository, there are over 200 packages you can install from the community repository without administrative permission - see =id%3Aportable+tag%3Aportable.

Once installed, Chocolatey can be upgraded in exactly the same way as any other package that has been installed using Chocolatey. Simply use the command to upgrade to the latest stable release of Chocolatey:

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.

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 ), 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.

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.

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.

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."

Are you using any secure environment variables in your build? There is a known issue where this can block the streaming output. We are working to address this, but in the mean time can you try removing the secure env vars and see if this helps?

Trying to set up the Windows build for rust-clippy, we managed to get the Pull Request builds to pass.
However, when we are using bors to approve the PR, the windows build fails without any errors when running choco install windows-sdk-10.0 -yv.
The same command is executed in a PR build without problems. This only seems to happen on the staging and trying branches.

Hi @josh, is there any update on this issue? Had assumed this was now fixed since we are seeing choco install consistently work fine in a Windows job we recently added on travis-ci.org (e.g. -ci.org/projectriff/riff/jobs/468099790) but, in an almost identical Windows job set up on travis-ci.com, the choco install repeatedly hangs as previously reported.

So, lets say I have a user JOE that is not an admin on the domain (neither on the machine) and a user PETER that is admin on both, and that I'm logged in as JOE. When I open a prompt (or powershell) as admin, windows UAC asks for a admin username/password. So I fill it with PETER's credentials. Then I can install Chocolatey (in C:\ProgramData\Chocolatey) and install packages on C:\ProgramData\Chocolatey\libs. And that is fine.

If the app is a install for all users (such as Sublime Text 3, installed at C:\Program Users folder), everything goes OK. But when I run a "single user" install (such as Wunderlist, which is installed at C:\Users\USERNAME\AppData\...) it get's installed at PETER's AppData and not JOE's AppData.

I've discovered how to do it for both administrative and non-administrative users. In the Chocolatey non-administrative section of the docs, it says that to install Chocolatey as non-admin, first we have to define a ChocolateyInstall environment variable pointing to a location where Chocolatey should be installed and all users have access (I've used C:\Users\Public\Chocolatey folder). That variable can be set at machine or user level. If we define it at machine level, the same Chocolatey installation can be used for both admin and non-admin packages installs. After setting the variable, we should procede to Chocolatey install, which can be done either as admin or non-admin user.

Then, to install any package there are two ways to do it: if it that requires admin access, we can open a an admin PowerShell (or command prompt) and call choco install with it. Then the app will be installed as the admin user (PETER in my question). If it doesn't require admin access, then we can open a non-admin PowerShell (or command prompt) and call choco install with it. The app gets installed to the current user (JOE in my question).

I've not tested it, but I believe that another option is to set a machine level ChocolateyInstall variable pointing to one location and a user level ChocolateyInstall variable pointing to another location. Then if we install Chocolatey as admin, we would get a "master" Chocolatey install, that can be used to install the majority of the packages (which require admin access according to the documentation). If we install it again as the common user, we would get a "user" Chocolatey install, that can be used to install some specific packages (as Wunderlist). That way, that package can get installed to any number of users, without interfering with the "admin" Chocolatey install.

Thank you Loenardo Puglia for your answer. Really helped me today. My example was Slack installs in $USERPROFILE%/AppData so I experienced this problem. I am, too, needing admin and non-admin use of Chocolatey.

If you've already installed chocolatey as admin (as I did), you can move it and turn it into non-admin, even under Active Directory. Then you can keep all your libraries. At least I did on 02/23/2017. This was the Open Source version of Chocolatey.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages