Chocolatey

A short tutorial on how to use Chocolatey to install, update, and manage Windows programs from the command line.

What is Chocolatey?

Chocolatey is a developer-centric package manager that allows you to install and update Windows applications through a command line interface. Unlike manual installations, Chocolatey handles the process of adding, updating, and uninstalling programs in the background, requiring very little user interaction.

The project is community-driven, and the package feed is maintained by members of the Chocolatey community.

Most Chocolatey packages are designed to download an application’s official executable and install it without further user interaction.

Advantages?

  • Chocolatey installs programs mainly from official sources, ensuring that you get the latest and most secure versions.
  • It provides an easy ‘one click’ solution for downloading and updating software, with a vast selection of available and well-maintained programs.
  • You still have control over the updating schedule, and there’s no need to manually check for updates.

How does it work?

  1. Install Chocolatey via PowerShell.
  2. Check the Chocolatey website for the programs you want to install. (the website)
  3. Install them via PowerShell
  4. Keep your programs up-to-date with Chocolatey & other maintenance tasks.

Installing Chocolatey

Run the following in an elevated PowerShell window:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

See official documentation.

Find the programs you want to install

The Chocolatey Website lists all available packages. For each package, you can find detailed information about the software, installation, update, and uninstallation commands.

For example, if you want to install Firefox, you can find the relevant commands and additional parameters available for the installation command - e.g. to create a taskbar shortcut, configure auto update, etc.

Installing software

Find packages at community.chocolatey.org/packages.

Example:

choco install firefox

Multiple programs:

choco install firefox atom notepadplusplus zotero

Disable desktop shortcut:

choco install firefox --params "/NoDesktopShortcut"

Batch install script example

:::::::::: Personal install script

:::: Install choco .exe and add choco to PATH
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

:::::: Cleans temp files once a week
choco install choco-cleaner -y

:::::: Browsers
choco install firefox -y
choco install googlechrome -y
choco install ungoogled-chromium -y

:::::: Text editors / IDEs
choco install atom -y
choco install notepadplusplus -y
choco install texstudio -y
choco install vscode --params "/NoDesktopIcon /NoContextMenuFiles /NoContextMenuFolders" -y

Full .bat script: Chocolatey_myInstallScript.bat

Updating software

Check for updates:

choco outdated

Upgrade one:

choco upgrade firefox

Upgrade all:

choco upgrade all

Freeze version:

choco pin firefox

Skip update once:

choco upgrade all --except="firefox"

Other commands

List installed:

choco list --local-only

Uninstall:

choco uninstall firefox

Clean cache

choco install choco-cleaner

Removes old logs and residual files.

More: Choco Cleaner