Installing Choco on Windows

Installing Choco on Windows

Introduction

Chocolatey is a popular package manager for Windows, streamlining the process of managing software on the operating system. It’s akin to what Apt is for Ubuntu or Homebrew for macOS.

Each time I install a Windows development machine, I install Chocolatey and then run a script to install each of the additional software packages and tools I need. This makes it easy to set up my environments each time, and gives me the freedom to wipe my machine whenever it gets into a mess.

Core Features

  1. Command-Line Interface: Chocolatey operates primarily through a command-line interface (CLI), allowing users to install, upgrade, and manage software packages with simple commands.
  2. Wide Range of Packages: It offers a comprehensive repository of software packages, including popular applications, tools, and utilities. These packages are maintained by the community and the Chocolatey team.
  3. Easy Installation and Upgrades: With simple commands, users can install or upgrade software without navigating through traditional GUI installers, streamlining the process significantly.
  4. Package Management: It allows for easy installation, configuration, updating, and removal of software. It can also manage dependencies, automatically installing necessary additional software.
  5. Version Control for Packages: Users can install specific versions of software, making it ideal for ensuring compatibility in development environments.
  6. Automation and Scripting: It integrates well with automation tools and scripts, making it a favorite for system administrators and DevOps for managing multiple Windows environments.
  7. Configuration Management Integration: Chocolatey can be integrated with popular configuration management systems like Puppet, Chef, and Ansible, allowing for automated and consistent configuration across numerous systems.

Installation

Installing Chocolatey on Windows is a straightforward process that allows you to manage software packages easily. Here’s a step-by-step guide:

Open Windows PowerShell as Administrator:

  • Press Win + X and select “Windows PowerShell (Admin)”.
  • On older versions of Windows, you might have to search for PowerShell in the Start menu, right-click on it, and choose “Run as administrator”.

Check Execution Policy:

Run Get-ExecutionPolicy. If it returns Restricted, you need to change the execution policy to allow scripts to run.

To do this, execute Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.

Install Chocolatey:Paste the following command:

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

Close and Reopen PowerShell:

After the installation, close PowerShell and open it again as an administrator to refresh your environment and have Chocolatey recognized in your session.

Verify Installation:

Run choco or choco -?. If Chocolatey is installed correctly, you will see the command help or version information.

Using Chocolatey:

  • To install a package, use choco install [package-name]. For example, choco install googlechrome to install Google Chrome.
  • To upgrade a package, use choco upgrade [package-name].
  • To list installed packages, use choco list --local-only.

Updating Chocolatey:

Run choco upgrade chocolatey to update Chocolatey itself to the latest version.

Uninstalling Chocolatey:

If needed, you can uninstall Chocolatey by manually removing the Chocolatey directory and its entries from the environment variables.

Remember, when using PowerShell or any other command-line tool, it’s crucial to understand the commands you are executing, especially those that require administrative privileges. This ensures that your system remains secure and stable.

Stephen

Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.