Chocolatey: a package manager for Windows

If you work with Linux or Mac you‘re more than used to deploy and maintain applications from the terminal of the operating system. On Windows it is less frequent, but there are occasions in which can be really useful a toolespecially when it comes to automate. Therefore, today I would like to talk to you about Chocolatey, a package manager for Windows, supported in PowerShell and the Nuget infrastructure.

Install Chocolatey

To start installing packages from the terminal with this manager, the first thing you should do is to open the console as administrator to launch the following command:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Instalando Chocolatey como administrador
Instalando Chocolatey como administrador

With that command you will install Chocolatey and will add it to the environment variables so that you can use it from anywhere. Realize that if you launch this command without being an administrator It will only be available to the user who launched the installation.

Also you can install it from PowerShell with the following command:

iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
In this case please note that you must have previously executed Set-ExecutionPolicy Unrestricted in order to run the previous line.

Once installed the package manager, you can install and automate the installation of various tools from command line. On the official site you have a search box to locate those that you need to know what is the name of the package.

Chocolatey website packages
Chocolatey website packages

As you can see, how to install them is very simple, just use the choco command followed by install and the package name.

choco install package_name

For example, to install Skype you could do so with the following command.

choco install skype

When this action is launched there is a script to run, but it is always possible to view the code to check the actions before accept.

Chocolatey print script
Chocolatey print script

Keep in mind that if you don’t execute the commands as an administrator, could get errors from installation, as it warns in console without elevated privileges.

Chocolatey detected you are not running from an elevated command shell
Chocolatey detected you are not running from an elevated command shell

Once accepted the installation, it will start downloading the necessary packages and record in chocolatey.log all the steps followed during the process.

Chocolatey - The install of skype was successful
Chocolatey – The install of skype was successful

To remove installed packages, you can do so through the uninstall action.

choco uninstall skype

If you want to know how many packages you have installed using Chocolatey simply launch the command list + —local-only.

choco list --local-only

You already know how to start with this simple package manager for Windows, so how many installations can you automate?

Cheers!