How to Install Chocolatey on Windows for Package Management

How to Install Chocolatey on Windows for Package Management

How to Install Software from Command Line with Chocolatey

Manually installing software off the internet can get tasking and complicated. It can get even more difficult if you are trying to install DevOps tools like Maven, Git, or Python. Managing software installations often requires specific dependencies. Despite the many online tutorials available, this task can still be challenging.

Package managers such as Chocolatey oversee the installation of software and any necessary prerequisites. They automate and streamline the entire process of generating software on your computer, as you only need to run a command.

Here, you will learn all there is to know about installing Chocolatey and how to install software on your Windows device using this tool.

What is Chocolatey?

Chocolatey is a package manager that simplifies installing, updating, configuring, and removing software on the Windows operating system. It works similarly to sudo apt-get in Unix-like systems regarding automated software installation and running on the command line.

One of the benefits of using Chocolatey is that it ensures software compatibility with your computer and reduces its size to optimize storage space. In addition, it has stringent security rules ensuring that your packages are secure and from licensed sources.

Chocolatey also has features that allow businesses to deploy applications from their computer using one command. Now, we will learn how to install Chocolatey on your computer.

Installing Chocolatey

To install Chocolatey on your Windows device, there are a few requirements you need to meet. They include;

  1. Administrative privileges on PowerShell.

  2. PowerShell version 2 and higher.

  3. Supported Windows version.

  4. .NET Framework version 4 and higher.

With those requirements in place, you can proceed to run PowerShell as an administrator to avoid getting any errors. You can find PowerShell by clicking the start command and searching for “PowerShell.”

With PowerShell running on administrator, you can now install Chocolatey with the following steps:

Run the command Get-ExecutionPolicy

Get-ExecutionPolicy denies, limits, or grants you access to run complex commands or scripts that may modify the internal workings of your computer. It ensures that you only run scripts from trusted sources.

Under normal conditions, the default setting for this command is Restricted. However, if your computer returns AllSigned, you can skip the next step.

Run Set-ExecutionPolicy Allsigned or Set-ExecutionPolicy Bypass -Scope Process

With whichever option you choose, you will receive a prompt that will require a "yes" response.

Run the download command below

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

After completing this step, Chocolatey should install smoothly. If you run into an error, an antivirus program may be the reason. In that case, disable any antivirus software running on your computer, open PowerShell as an administrator again, copy the command above, and install Chocolatey.

To confirm if you have Chocolatey installed, run the choco command.

Now, you are ready to install and manage software from your command line.

Installing and Managing Software Packages with Chocolatey

The official Chocolatey community website has over 5000 licensed packages you can install. To install a package, you search for the name of the package on the Chocolatey website, copy the command for installing that package, and run it on PowerShell. Alternatively, you can execute the command choco install <app name> if you already know the name of the app you need to install.

Chocolatey has many commands that make managing each package you install easy to manage. To learn more about these commands and how to navigate them, you can read the official Chocolatey documentation.

If you prefer a graphical interface for interacting with installed packages, Chocolatey also offers a subset feature called Chocolatey GUI. This tool facilitates visual interaction with software installed using the choco command.