DEV Community

Cover image for Chocolatey Installation and Usage Guide
Bello Osagie
Bello Osagie

Posted on

Chocolatey Installation and Usage Guide

What is Chocolatey?

Chocolatey is a package manager for Windows that simplifies the installation, updating, and management of software applications and command-line tools. Similar to Homebrew on macOS, Chocolatey allows users to automate software installations using a single command.

Checking Your PowerShell Execution Policy

Before installing Chocolatey, ensure that your PowerShell execution policy allows scripts to run. Open PowerShell as an administrator and check the current policy:

Get-ExecutionPolicy 
Enter fullscreen mode Exit fullscreen mode

If it returns Restricted, change it to AllSigned or Bypass temporarily:

Set-ExecutionPolicy Bypass -Scope Process -Force 
Enter fullscreen mode Exit fullscreen mode

This allows Chocolatey to run its installation scripts without restrictions.


Installing Chocolatey

Step 1: Open PowerShell as Administrator

  • Press Win + X and select Windows Terminal (Admin) or PowerShell (Admin).

Step 2: Run the Installation Command

Copy and paste the following command into the terminal:

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')) 
Enter fullscreen mode Exit fullscreen mode
  • Press Enter and wait for Chocolatey to install.
  • Close and reopen PowerShell to apply changes.

Step 3: Verify Installation

Run the following command to confirm Chocolatey is installed:

choco -v 
Enter fullscreen mode Exit fullscreen mode

If Chocolatey is installed correctly, it will return the installed version number.


Installing Git Using Chocolatey

Installing Git via Chocolatey ensures you always have the latest version and simplifies updates.

choco search git # Search for Git choco install git -y # Install Git without confirmation prompt 
Enter fullscreen mode Exit fullscreen mode

Verify Installation

git --version # Check Git version where.exe git # Locate Git installation 
Enter fullscreen mode Exit fullscreen mode

Installing Software with Chocolatey

Chocolatey provides two package types:

  • Standard Packages (CLI tools like git, nodejs)
  • GUI Applications (Apps like Google Chrome, VS Code)

Installing a CLI Package

choco install nodejs -y # Install Node.js 
Enter fullscreen mode Exit fullscreen mode

Installing a GUI Application

choco install googlechrome -y # Install Google Chrome 
Enter fullscreen mode Exit fullscreen mode

The -y flag skips confirmation prompts.


Managing Chocolatey Packages

Listing Installed Packages

choco list --local-only # View installed packages 
Enter fullscreen mode Exit fullscreen mode

Upgrading Installed Packages

choco upgrade all -y # Upgrade all installed packages 
Enter fullscreen mode Exit fullscreen mode

Uninstalling a Package

choco uninstall <package-name> -y # Remove a specific package 
Enter fullscreen mode Exit fullscreen mode

Running Chocolatey in Scripts

To automate installations in scripts, use Chocolatey commands within .ps1 files. Example:

# Install multiple applications choco install git vscode nodejs googlechrome -y 
Enter fullscreen mode Exit fullscreen mode

Run the script in an elevated PowerShell session to execute commands.


Chocolatey GUI: A Visual Interface

For users who prefer a graphical interface, install Chocolatey GUI:

choco install chocolateygui -y 
Enter fullscreen mode Exit fullscreen mode

Run Chocolatey GUI from the Start Menu to manage software visually.


Uninstalling Chocolatey

If you need to remove Chocolatey, run:

choco uninstall chocolatey -y 
Enter fullscreen mode Exit fullscreen mode

Then manually delete the C:\ProgramData\chocolatey folder to clean up residual files.


Exploring More Chocolatey Commands

choco help # View available commands choco info <package-name> # Get package details choco outdated # Check for outdated packages 
Enter fullscreen mode Exit fullscreen mode

For a full package list, visit Chocolatey Community Repository.


Chocolatey simplifies Windows package management, making software installations fast and efficient! 🚀

Top comments (0)