Choco For Windows
Contains tasks which allow to call Chocolatey. Args - string that will be appendedn to choco.exe call. True if choco is available (only on windows). Chocolatey, Scoop, and Ninite are probably your best bets out of the 8 options considered. 'Large number of applications/utilities available' is the primary reason people pick Chocolatey over the competition. This page is powered by a knowledgeable community that helps you make an informed decision.
Requirements
- Windows 7+ / Windows Server 2003+
- PowerShell v2+ (Not PowerShell Core yet though)
- .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)
That's it! All you need is choco.exe (that you get from the installation scripts) and you are good to go! No Visual Studio required.
Installing Chocolatey
Chocolatey installs in seconds. You are just a few steps from running choco right now!
- First, ensure that you are using an administrative shell - you can also install as a non-admin, check out Non-Administrative Installation.
- Copy the text specific to your command shell - cmd.exe or powershell.exe.
- Paste the copied text into your shell and press Enter.
- Wait a few seconds for the command to complete.
- If you don't see any errors, you are ready to use Chocolatey! Type
choco
orchoco -?
now, or see Getting Started for usage instructions.
NOTES:
- If you are behind a proxy, please see Installing behind a proxy.
- Need completely offline solution? See Completely Offline Install.
- Installing the licensed edition? See install licensed edition.
- More Options / Troubleshooting
Install with cmd.exe
Run the following command:
Install with PowerShell.exe
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.
- Run
Get-ExecutionPolicy
. If it returnsRestricted
, then runSet-ExecutionPolicy AllSigned
orSet-ExecutionPolicy Bypass -Scope Process
. - Now run the following command:
Additional considerations
NOTE: Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it's safe, but you should verify the security and contents of any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine.
We take security very seriously. Learn more.
More Install Options
Install from PowerShell v3+
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.
- Run
Get-ExecutionPolicy
. If it returnsRestricted
, then runSet-ExecutionPolicy AllSigned
orSet-ExecutionPolicy Bypass
. - Now run the following command:
Completely offline install
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 -n chocolatey
, or however you would do that with a configuration manager like Puppet).
- The first step with offline is to obtain a copy of the Chocolatey Nupkg (nupkg files are just fancy zip files). Go to https://chocolatey.org/packages/chocolatey and find a version you want.
- Click on Download to download that version's nupkg file.
- You can also download the latest version directly.
- You can put the chocolatey.nupkg on an internal package repository and then address that full path, similar to how you see in the Puppet provider - https://forge.puppet.com/puppetlabs/chocolatey#manage-chocolatey-installation
- Then you would run a script similar to the below to address that local install. If it is on a repository somewhere, you will need to enhance the below script to get that file (the Chocolatey Puppet provider install script shows that).
Install with Puppet
NOTE: If you have the licensed edition, see Setting up Licensed Edition with Puppet instead. This only additionally contains some package examples and setting up tab completion.
Here's an example of setting Chocolatey up with Puppet that sets up and configures Chocolatey, sets up an internal package repository, and shows setting up the licensed edition and ensuring some packages.
- Download the chocolatey.nupkg from the community repository - download the latest chocolatey nupkg or see Completely offline install to get an older version.
- Optionally download the chocolatey.server package from the community repository - download the latest chocolatey.server nupkg.
- Use
choco push
to push those items to your internal package repository (e.g.choco push chocolatey.0.10.7.nupkg -s http://internal_repo/ -k abc123
) - Determine how to get the bare url to download the Chocolatey.Nupkg directly. You will need that for the internal url for installing Chocolatey offline. For the community repository, it is https://chocolatey.org/api/v2/package/chocolatey
Install using PowerShell from cmd.exe
This is the best method if you want to repeat it or include it in source control. It requires no change to your existing PowerShell to allow for remote unsigned scripts.
Create a file named installChocolatey.cmd
with the following:
You can also get to this file by going to https://chocolatey.org/installchocolatey.cmd.
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 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.
NOTE: To create and save a .cmd
file, please use a text editor and nothing fancy like Microsoft Word or OneNote.
Install using NuGet Package Manager
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.
Install-Package chocolatey
Initialize-Chocolatey
Uninstall-Package chocolatey
Install using NuGet.exe from PowerShell
You can also use NuGet command line to download Chocolatey:
nuget install chocolatey
or nuget install chocolatey -pre
Once you download it, open PowerShell (remote unsigned), navigate to the tools folder and run:
& .chocolateyInstall.ps1
Install downloaded NuGet package from PowerShell
You can also just download and unzip the Chocolatey package (.nupkg
is a fancy zip file):
- Download the Chocolatey package.
- Ensure the downloaded nupkg is not blocked.
- Unzip it using any application that supports
zip
format. - Open a PowerShell command shell and navigate into the unzipped package's tools folder.
- NOTE: Ensure PowerShell execution policy is set to at least bypass or remote signed (if you have issues, you may need to set it to Unrestricted).
- Call
& .chocolateyInstall.ps1
to allow Chocolatey to install. - NOTE: 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.
Install licensed edition
Please see installation of licensed edition.
Installing behind a proxy
Have a proxy? Try
- Cmd.exe:
- PowerShell.exe (Ensure Get-ExecutionPolicy is at least RemoteSigned):
Installing behind an explicit proxy
See Installing Chocolatey Behind a Proxy Server
Installing to a different location
- Create a machine level (user level will also work) environment variable named
ChocolateyInstall
and set it to the folder you want Chocolatey to install to prior to installation (this environment variable must be set globally or available to PowerShell- it is not enough to simply make it available to your current command prompt session). - Don't use
'C:Chocolatey'
unless necessary. - Create the folder manually.
- If you have already installed (and want to change the location after the fact):
- Follow the above steps.
- Install Chocolatey again.
- Copy/Move over the items from the old lib/bin directory.
- Delete your old install directory.
NOTE: 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%ProgramDataChocolatey
.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 https://github.com/chocolatey/choco/issues/398 for more details.
Installing a particular version of Chocolatey
Set the following environment variable prior to install:
chocolateyVersion
- controls what version of Chocolatey is installed
In PowerShell, it looks like this:
NOTE: This will only work with the installation methods that call https://chocolatey.org/install.ps1 as part of the install.
Use Windows built-in compression instead of downloading 7zip
Set the following environment variable prior to install:
chocolateyUseWindowsCompression
- this will bypass the download and use of 7zip.
In PowerShell, it looks like this:
NOTE: This will only work with the installation methods that call https://chocolatey.org/install.ps1 as part of the install.
Installing with restricted TLS
NOTE: 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). If this is for organizational use, you should consider hosting the Chocolatey package internally and installing from there. Otherwise, please see this section.
If you see an error that looks similar to the following:
It's possible that you are attempting to install from a server that needs to use TLS 1.1 or TLS 1.2 (has restricted the use of TLS 1.0 and SSL v3), you have some options.
Option 1
If you have the following:
- PowerShell v3+
- .NET Framework 4.5
You can just run the following instead of just the one-liner to get Chocolatey installed:
Option 2
You need to download and unzip the Chocolatey package, then call the PowerShell install script from there. See the Download + PowerShell Method section below.
Non-Administrative install
NOTE: 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 https://chocolatey.org/packages?q=id%3Aportable+tag%3Aportable.
- You must choose a different location than the default (see Installing to a different location above). The default is a more secure location that only administrators can update.
- Follow that with the command line / PowerShell methods of installation.
- Here is an example of this.
NonAdmin.ps1:
If you prefer or need cmd.exe example, please see https://gist.github.com/ferventcoder/78fa6b6f4d6e2b12c89680cbc0daec78
Upgrading Chocolatey
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:
Uninstalling Chocolatey
See uninstall.
FAQs
I'm having trouble installing Chocolatey
Make sure you've reviewed More Install Options and looked over Troubleshooting. If you've done those things, reach out over the mailing list or over the chat (Gitter). The links to those can be found in the open source section of https://chocolatey.org/support.
I'm getting a 403 attempting to install
This is addressed in Troubleshooting.
Why isn't there an MSI?
tl;dr - Chocolatey installs as a nupkg like everything else, a PowerShell install script just ensures that.
Chocolatey was born out of providing automation for Windows and doing that with packages, packages that could surround an installer but didn't necessarily need to. The Chocolatey install scripts use the Chocolatey package (a nupkg file itself) to be installed and upgraded as just another package. This means Chocolatey is 'eating its own dogfood' and it is unlikely we'd offer it as an MSI (native installer)as it would fly a bit in the face of what Chocolatey represents (although it is something that we would not rule out).
The installation actually ensures a couple of things:
PowerShell is installed and is set up properly.
PowerShell is a requirement for using Chocolatey, not just for install. It is what drives the package installation process in most cases. Every package can have binaries and/or installation/uninstallation scripts (written in PowerShell). Chocolatey is the framework and each package gets to define how it is installed, upgraded, and uninstalled. It's an extremely flexible framework that has been proven to meet the insanity that is the Windows software installation ecosystem. That flexibility would not be easily achieved without PowerShell.
We do recognize there are a few organizations that disable PowerShell, so it's very likely in the future our Business Edition will meet that need. PowerShell is a staple of Windows automation, so it is not the norm for an organization in this day and age to disable PowerShell.
Having an install process that uses PowerShell helps you determine quickly if Chocolatey will be able to be used in your environment.
You are open to doing things in a slightly different way, e.g. working with packages as opposed to installers.
You are open to the concept of using packages. Some folks might say this means we are asking folks to learn to 'do things 'our way' because we know better'. It's less about 'knowing better' and more about learning that Chocolatey does things in a slightly different way. It does that because the world of software is not just installers. Software goes beyond Programs and Features and a system that can track all of that also needs to as well. Package management is not a new concept in the world of software, perhaps just newer to Windows. If folks are not open to that, then they are probably not going to be open to Chocolatey. And that's completely fine. Chocolatey is not for everyone. We may eventually get to more of a masses approach. Right now we are targeting a specific type of audience - those that are looking for better ways to manage software on Windows and open to looking for the best process of doing that.
OneGet is to Windows what apt-get and yum are to Linux.
Back in April of this year, Jeffrey Snover from the Windows Server team, teased the power of a new package management program coming to Windows called OneGet.
The beauty of OneGet is that it gives you access to over 2,300 software packages directly from the command line. There’s no need to visit the stupid Microsoft Store or sift through Google search results. You can now install hundreds of packages directly from the Powershell command line with ease.
Moreover not only let’s you install and uninstall packages with simple commands but you can also easily search through repositories so you can grab exactly what you need.
It’s really a beautiful thing and today I’m going to show you how to use it.
Here’s how to get started.
Getting OneGet
Fire up Windows 10, kick open PowerShell and type:
After a few seconds the command prompt will return awaiting your input.
So what can we do with OneGet?
We’ll lets list the command and see!
Type:
I’m seeing:
- Find-Package
- Get-Package
- Get-PackageProvider
- Get-PackageSource
- Install-Package
- Register-PackageSource
- Save-Package
- Set-PackageSource
- Uninstall-Package
- Unregister-PackageSource
The first thing we need to do is add a monster software repository called Chocolatey.
Adding Chocolatey to OneGet
By default you’ll only see the PSGallery and MSPSGallery repos but these guys are very limited. SO we need the delicious chocolatey repo. And I mean – with a name like “chocolatey” who can resist it?
If you search the web you’ll see a few people using the Add-PackageSource cmdlet to add the Chocolatey repository. But in the Windows 10 Technical Preview, Add-PackageSource was actually replaced with Register-PackageSource so that’s what I’m using.
Here’s the command we need to use to add the Chocolatey repo into OneGet:
Now we can have some serious fun.
First, head on over to chocolatey.org/packages to see all the packages at your disposal.
Let’s say I want to install Google Chrome. I can search for it:
Or just install it like so:
Try experimenting with different package names. For example put in:
- Install-Package -Name VLC
- Install-Package -Name Firefox
- Install-Package -Name flashplayerplugin
You can also easily uninstall programs with the Uninstall-Package cmdlet.
Nice eh?
The Bottom Line
There’s got to be a way to list packages from the command line but I haven’t figured that out yet. If you know please share in the comments.
Also, although I can easily install and uninstall packages, I haven’t found an Update-Package cmdlet. This would be extremely useful and I hope Microsoft considers adding it.
Choco For Windows
So what do think about OneGet? Will Microsoft use this as a way to install ModernUI Apps?
I personally don’t see that happening because this tool is better suited for Powerusers but I guess the possibility is there. Let me know what you think in the comments below!