Installing Chocolatey

What is Chocolatey?

Chocolatey is a package manager for Windows that allows users to install, upgrade, and manage applications and tools in a simple and efficient way. It is an open-source project that provides a command-line interface for automating software installations and upgrades on Windows. With Chocolatey, users can install software packages with a single command, and the packages can be managed, updated, and uninstalled with ease. Chocolatey packages are built using a standard packaging format, which makes it easy for developers to create and distribute packages for their applications. The goal of Chocolatey is to simplify software management on Windows, making it faster and easier to install and manage applications, tools, and other software components.

Installing Chocolatey

To install Chocolatey on a Windows computer, you need the following:

  • A Windows computer with administrative rights.
  • The latest version of PowerShell, which is included with Windows 7 SP1 and later versions.
  • An internet connection to download the installation script and packages from the internet.
  • If your computer is behind a proxy, you will need to configure the proxy settings in PowerShell before you can install Chocolatey. You can do this by running the following command:
$env:http_proxy = "http://<proxy server>:<port>"
$env:https_proxy = "http://<proxy server>:<port>"

Replace <proxy server> and <port> with the values for your proxy server.

First, open an elevated PowerShell window and  run the following command to install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))

Here’s a breakdown of what it does:

Set-ExecutionPolicy Bypass -Scope Process -Force: This command sets the execution policy of the current PowerShell process to “Bypass”, which means it allows the execution of all scripts, including unsigned and unverified scripts, without prompting the user.

iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’)): This line downloads and executes the Chocolatey installation script from the official Chocolatey website. iex stands for “Invoke-Expression”, and it runs the contents of a string as a PowerShell command. The script that’s being downloaded and run is the official installation script for Chocolatey, which installs the package manager on the computer.

You can run choco -v to confirm that it is properly installed.

Searching for Packages

To search for packages in Chocolatey, you can use the following command from an admin command line:

choco search <package name>

Replace <package name> with the name of the package you’re looking for. For example, if you’re searching for the Firefox package, you would run the following command:

choco search firefox

This will return a list of all packages that match the search term. You can then choose the package you want to install and use the choco install command to install it, like this:

Installing Packages

Once you have identified the packages you want to install, it is very easy to install packages using chocolatey. The first step is to open an elevated PowerShell window. Then, if you want to install Firefox, you would run the following command:

choco install firefox -y

The -y on the end is to tell it not to prompt you to confirm that you want to install. After you run the command, it will go to the chocolatey gallery, pull down the nuget package, then reach out to the appropriate URL and pull down the installer, then run the installer in silent mode. When the process is complete, you will have Firefox installed.

While this is great for one application, the magic of Chocolatey is that is will also allow you to install multiple applications at once.

Installing a list of applications

You can install a list of applications from a text file using the following steps:

  1. Create a text file with the names of the packages you want to install, one package name per line.
  2. Save the text file with a .txt extension, for example packages.txt.
  3. Open the Start menu, search for “Windows PowerShell”, and select “Windows PowerShell” from the results.
  4. Right-click on “Windows PowerShell” and select “Run as administrator”.
  5. In the PowerShell window, run the following command to install all packages from the text file:
Get-Content .\packages.txt | ForEach-Object { choco install $_ -y}

Note that you should replace .\packages.txt with the path to your text file, if it’s not in the current directory.

This command will read the contents of the text file, one line at a time, and install each package using the choco install command. The $_ symbol in the script represents the current line being processed in the loop.

Once the script has finished running, all of the packages in the text file should be installed on your computer. In this case I just installed Greenshot and Google Chrome.

This can be extremely useful when creating new OS builds or Virtual Machines where you can just populate the txt file with a list of software you would like to install post install.

Leave a Reply

Your email address will not be published. Required fields are marked *