How to Make Linux-Style Apt-get Installations Come To Windows with Chocolatey

Linux users love installing software from the command line, and it’s not hard to understand why. Instead of downloading executables, running them, and dodging the various attempts to change your default search engine, you basically type what you want to install and hit “Enter.”

If you want this kind of peace on Windows, look no further than Chocolatey, the package manager for Windows. This free tool lets you install thousands of apps with just a quick command (choco install), and update them all with another (choco upgrade.) This can save you a lot of time if you’re the kind of person who installs a lot of free software.

You can use Chocolatey in two places: the Command Prompt and PowerShell. Here’s how to install this package manager in both environments, but you only really need one or other other. Pick whatever you’re comfortable with.

Install and Use Chocolatey From the Command Prompt

Chocolatey only works in the Command Prompt if you run it as administrator. The easiest way to do this is to right-click the Command Prompt in the Start Menu, and then click “Run as Administrator.”
To install Chocolatey, first you need to run the following command, which downloads and runs the installer for you:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
This command could change, so check the official Chocolatey instructions if you’re having trouble.
After you install Chocolatey, you can use it immediately (though in some cases you might need to close and re-open the admin Command Prompt). Installing software is simple: simply type choco install followed by the name of the program. Here, we’re running choco install filezilla to install the popular Filezilla FTP client.
You also don’t have to limit yourself to installing one app at a time. For example, using the following command will install all the listed apps in one go:
choco install firefox thunderbird vlc libreoffice
Of course you’ll need some way of knowing which packages exist and how they’re named. You can search to see if a given app is offered by using the following syntax:
choco search key_word
In the following screenshot, for example, we’re using choco search thunderbird to search for packages related to the Thunderbird email client.
Alternatively, this website offers a complete list of all packages you can install, complete with its own search tool.
If you want to upgrade a specific package to the latest version, use the command choco upgrade, followed by the package name. If you want to upgrade everything you’ve installed using Chocolatey in one go, choco upgrade all will do the trick. And there are more sub commands if you feel like digging. Just type choco -? to see a complete list.

Install and Use Chocolatey in PowerShell

If you’re a big fan of PowerShell, you can use Chocolately from there as well. This means you can automate all kinds of things, once you get started with PowerShell and learn the ropes.
You’ll need to open an administrator PowerShell to get started. The simplest way to do that is to right-click the Start button, and then click “Windows PowerShell (Admin).”
Chocolatey, by its nature, requires permission to run scripts from outside your computer. For this reason, the official installation instructions recommend you change the ExecutionPolicy before installing Chocolatey. First, at the PowerShell prompt, type the following command and hit Enter:
Get-ExecutionPolicy
If you see a “Restricted” result, then you need to run the following command to set your execution policy so that the Chocolatey installation will work:
Set-ExecutionPolicy AllSigned
The command Set-ExecutionPolicy Bypass could also work, though this is the less secure option: it allows any script to run, regardless of whether its signed by the developer.
After setting the execution policy, you can run the installer using the following command:
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Just like that Chocolatey is installed! Using Chocolatey in Powershell is much the same as in the Command Prompt. Here’s choco install firefox running:
Subcommands like search and upgrade also work just like in the Command Prompt, and choco -? will give you a list of other functions. Have fun!




RELATED ARTICLES