Chocolatey: A beginners guide to windows package management

Ever wish there was an app store for Windows for installing apps like Microsoft Office, Acrobat Reader, Steam, Dropbox, Google Chrome, Skype or Firefox?

If you have ever set up a new computer or reinstalled Windows? You know the pain of having to find and install all your favorite apps just to get your device back to a useful state.

Imagine for a second that you had a cute, playful minion or robot that would do all that dirty work for you. Wouldn't that be awesome?

There is one. It's called Chocolatey. Chocolatey is a package manager for windows.

A package manager can download, install, remove, or upgrade apps from various places around the web without forcing you to leave the comfort of your desktop screen.

What are packages?

Most software vendors store software programs in packages like .zip, .msi, .exe, or .deb files. Packages are a convenient way to compress and move around multiple files as one file.

You've seen this before at grocery stores when you purchase your items.

A store employee takes all your items and temporarily stores them in bags which makes it easier for you to carry them home where they are unpacked.

Software packages and installers use the same concept.

Some package types like a .msi or .exe contain extra instructions do more than just extract the files like create desktop or start menu shortcuts but at the end of the day, installers still just glorified zip files.

The are a few problems with installing packages in the traditional manner:

  • Packages exist on different sites all over the web rather than one place
  • Very, very few people verify package checksums. Ain't nobody got time for that.
  • Windows only installs one package at a time. This limitation requires manual work and steals precious time.

Package Managers

Package managers are not a new concept.

Mac computers, in true hipster fashion, have a package manager called Homebrew. Homebrew was around before the Apple App Store.

Linux machines have several package managers. The most popular package managers are apt-get and yum.

App stores are the e-commerce versions of package managers. Well-known apps stores are prettier due to their funding and the need to seduce users into making purchases.

Download apps on your phone? You're already using a package manager.

Package managers solve all the issues mentioned above. Package managers allow you to:

  • Download and install software without having to go to different web pages.
  • Verify packages have not been tampered with so that you don't end up with malware from MITM attacks.
  • Install multiple packages for you and even make sure to install other software that an app may require.
  • Upgrade and remove packages
  • Search for packages.
  • And much more.

What to know before installing Chocolatey

There are a couple of ways to install to install chocolatey; I'm going to focus on one.

By default, Chocolatey installs itself to a folder in C:\ProgramData, a hidden windows folder that requires the Windows Administrator role to access.

If you are the person that set up your computer, then you most likely have the Windows Administrator role attached to your account.

If you do not have Windows Administrator role, you will need to instruct Chocolatey to install to a different location by specifying the $Env:ChocolateyInstall variable. Users are limited in program choices if they do not have Administrator privileges.

Most packages install to C:\Program Files or C:\Program Files (x86). To copy files to these folders, a user must have Administrator privileges.

There are ways to get around this, but that is another post for an another day.

Installing Chocolatey

Note: The slideshow feature for articles has been temporarily disabled while switching to a new blog.

Step 1: Open the Start Menu

Click the Windows Key. This opens the start menu.

Step 2: Find Powershell

PowerShell is a tool that enables you to text message your computer and it is installed on all windows machines since Vista.

Type PowerShell into the Start Menu.

PowerShell should appear at the top of the menu. start menu powershell

Step 3: Open PowerShell As An Administrator

Right-click on the PowerShell icon. A context menu will appear.

Select Run as Administrator run as

Step 4: Say Yes.

A UAC window will crash the party and ask you if you want to let PowerShell come out and play.

Click Yes

uac window

Step 5: Understand Pasting with PowerShell

Before Windows 10, pasting into shells like PowerShell or cmd is not intuitive.

To paste text into a shell on windows:

  • Click the top white bar on the PowerShell window with your mouse. You should now see the white cursor blink; often this is an underscore _.
  • Right-click with the mouse. The pasted text will appear.
  • If you have Windows 10 and Enable Ctrl key shortcuts is enabled, you can paste text with ctrl + v.

Step 6: Set the execution policy

Copy the snippet below. Paste into PowerShell. Hit the Enter key to execute.

Set-ExecutionPolicy Unrestricted -Force -Scope Process

The command instructs PowerShell to let you run scripts for this session. Once you close the PowerShell window, it will default back to the original execution policy.

Step 7: Download and Install Chocolatey

Copy the snippet below. Paste into PowerShell. Hit the Enter key to execute.

iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

This command downloads the install.ps1 file from the website and then executes the script that installs chocolatey.

Do not run this from an unsecured location like a coffee shop or hotel wifi.

Step 8: Verify Chocolatey

Copy the snippet below. Paste into PowerShell. Hit the Enter key to execute.

choco --version

This command will instruct chocolatey to output its version which should be 0.10.0 or higher. If there is red text on your PowerShell screen, something went wrong.

Using Chocolatey

Step 9: The Search Continues

Type the following in PowerShell and hit the Enter key to execute.

choco search ChocolateyGUI

This command will list out packages that match search criteria. We want to install ChocolateyGUI, to which I affectionately call GUIChocolatey (gooey chocolatey).

Step 10: Install Gui-Chocolatey :wink:

Type the following into PowerShell and hit the Enter key to execute.

choco install ChocolateyGUI -y

This command tells Chocolatey to install the package. The -y flag reduces the extra step(s) of typing yes to any of the prompts during the install, e.g. accepting the software license. ChocolateyGUI is the name and id of the software package we want to install.

If you wanted install skype, the command would be choco install skype -y

Step 11: Verify the install

Type the following into PowerShell and hit the Enter key to execute.

choco list -l

This command lists packages. By default, it will list everything in the chocolate store. The -l flag tells Chocolately to list local packages instead. You should see ChocolateyGUI in the list of packages.

Step 12: Clean up GuiChocolatey

Type the following into PowerShell and hit the Enter key to execute.

choco uninstall ChocolateyGUI -y

This command will uninstall GuiChocolatey from your machine.

Step 13: Verify GUIChocolatey has 👻ed.

Type the following into PowerShell and hit the Enter key to execute.

choco list -l

And ChocolateyGUI is not listed

Congratulations. You've taken your first step into a larger world.

Anytime you want to install new software:

  • Repeat Steps 1 - 4 to open PowerShell
  • Repeat Step 10 by replacing the package name. e.g. choco install GoogleChrome -y will install the Chrome browser.

If you want to use something more visual to search for available software, I'd recommend checking out the packages page on the Chocolatey website.

If you want to use something that feels more like a regular windows app to install software, reinstall ChocolateyGui. choco install chocolateygui -y

The current preferred method is to use Chocolatey from a shell like PowerShell.

  • ChocolateyGUI is limited in what it can do
  • Learning to use the command-line gives you a competitive advantage.

There is a new version of the GUI tool that being developed. It looks better and has a few more features like supporting multiple feeds, but it still lacks all the features of the shell version.

I've been using the free version for years. There are now various pricing options including the free version.

If you're worried about viruses and malware, the paid options will scan for viruses on your local machine before installing any package.

For more information about Chocolatey, you can hit up their Documentation which has been significantly cleaned up.

If you want to take it to the next level and script your computer setup, I'd suggest checking out the install command in the docs. You can either create a Powershell file. e.g. InstallApp.ps1 that runs all your software installs or look at the packages.config section of the install page.

Rob Reynolds created Chocolatey. RealDimensions Software, LLC owns and maintains Chocolatey. Rob was kind enough to provide a media kit for this article.

Disclaimer: I sponsored Chocolatey in a Kickstarter campaign because I believe it makes the Windows world a better place.

If you like this content and want more: Follow BadMishkaLLC on social media. The links are in the sidebar and the bottom of the page.