Manage your apps without losing your mind

Michael Herndon

February 24th, 2016

Setting up a new computer, reinstalling windows, updating software, or managing the apps on multiple computers is a hassle. Even after the creation of app stores, like the Windows store, finding and managing the right apps for your Windows desktop is still a tedious chore.

Work is piling up, and the last thing you need to worry about is hunting down and reinstalling your favorite apps after a recent computer crash.

Thankfully there is already a solution for your app management woes called package managers. It's not the most intuitive name but the software gets the job done.

If you're wondering why you haven't heard of package managers, they are a poorly marketed tool. Even some software developers that I have met over the years are unaware of their existence.

All of which begs the question, what is a package manager?

What is a package manager?

It's a system of applications that control the installation, updates, and removal process of packages on platforms such as Windows or OSX. Packages can bundle one or more applications or parts of applications and include the scripts to manage these items.

You could think of it as an app store that includes the apps that your device forgot to add for your desktop.

The Linux world has had package managers like apt-get and yum for years.

Macs have a package manager called homebrew.

For Windows, there is a tool called Chocolatey. Chocolatey stands for Chocolate nugget, a play on words that acknowledges that the package manager is built on top of a Microsoft technology called nugget. It can install applications like Evernote, OneDrive, OneNote, and Google Chrome from within one location.

What are the benefits of package managers?

The benefits of package managers are repeatability, speed, and scale.

  • Repeatability, a package can be installed on the same machine multiple times or on multiple machines.
  • Speed, a package manager makes it easy to find, download, and install the software within a few keystrokes.
  • Scale, a package manager can be used to apply the same software across multiple computers from a home network to a whole company. It can also install multiple packages at once.

Let us assume that that a company wants to install Google Chrome, Paint.Net, and custom company apps. The apps require specific installations of Java and .NET.

A package manager can be used to install all those items. The company will have to create their packages for their custom apps. The packages will need to specify dependencies on Java and.NET.

When the package manager detects a required dependency, the dependency is installed before the app is.

The package manager can apply a required list of programs to all the machines in an organization. The package manager is also capable of updating the applications.

For the remainder of the article, I will focus on using Chocolatey as the package manager for Windows.

Get Chocolatey

To run Chocolatey, you need a program called Powershell. Powershell exists on Windows 7 and above or Windows Server 2008 and above.

Open Powershell from the start menu.

Go to chocolatey.org, copy the installion code, iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')). Paste the code into the blue shell.

PS C:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

Press Enter.

This will install Chocolatey on your machine.

Customize the Chocolatey Install

Chocolatey has two configuration options for installation.

$env:ChocolateyInstall will instruct Chocolatey to install itself to the specified path. The default is c:

$env:ChocolateyBinRoot will instruct Chocolatey to install programs that are folder based like PHP or MySQL at the given location. The default is c:

For example, let us assume the company wishes to customize Chocolatey's install. It wants Chocolatey to exist in the folder c:. It also wants the bin root folder to use c:.

Type or copy $env:ChocolateyInstall = "c:\opt\chocolatey"; into Powershell and hit enter.

PS C:\> $env:ChocolateyInstall = "c:\opt\chocolatey";

Type or copy $env:ChocolateyBinRoot = "c:\opt\chocolatey"; into Powershell and hit Enter.

PS C:\> $env:ChocolateyBinRoot = "c:\opt\chocolatey";

Copy the Chocolatey install code into Powershell and then hit Enter.

PS C:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

Use Chocolatey

After Chocolatey's installation finishes, you can search for packages from the command line.

List all programs with GoogleChrome in the name.

To list packages, you will use the list command.

Type choco list GoogleChrome into Powershell and hit Enter.

PS C:\> choco list GoogleChrome

List all packages

Type choco list into Powershell and hit Enter.

PS C:\> choco list

List all packages and write them to a file

Type choco list > c:\users\mhern\Desktop\packages.txt into Powershell. Replace "mhern" with the name of your user folder on Windows. Hit Enter.

PS C:\> choco list > c:\users\mhern\Desktop\packages.txt

Install chrome

To install a package like GoogleChrome you will use the install command.

Type choco install chrome GoogleChrome -y into Powershell and hit Enter. The flag, -y, means that you accept the license agreement for the software that you are installing.

PS C:\> Choco install GoogleChrome -y

Install multiple programs

Type choco install php mysql -y into Powershell and hit Enter. This will install PHP and MySQL onto your Windows machine. PHP and MySQL will be installed into c:\tools\ by default.

PS C:\> choco install chrome PHP MySQL -y

Upgrade a program

To upgrade a program with Chocolatey, you will use the upgrade command. In older versions of Chocolatey it was the update command.

Type choco upgrade GoogleChrome -y into Powershell and hit Enter. Though you really do not need to update GoogleChrome as it will update itself.

PS C:\> choco upgrade GoogleChrome -y

Upgrade all programs

Type choco upgrade all -y into Powershell and hit Enter.

PS C:\> choco upgrade all -y

Upgrade Chocolatey

Type choco upgrade chocolatey into Powershell and hit Enter.

PS C:\> choco upgrade chocolatey

Uninstall chrome

To uninstall a package, use the uininstall command.

Type choco uninstall GoogleChrome into Powershell and hit Enter.

PS C:\> choco uninstall GoogleChrome

Further reading

Now you should be able to find and install applications with ease. If you want to investigate Chocolatey further, I suggest reading through the wiki and familarizing yourself with Powershell and running Powershell as administrator.

Disclosure

I supported Chocolatey's kickstarter campaign.

Now you can install apps with ease, read our article on the essential command line tools for DevOps and build up an impressive skillset!

About the author

Michael Herndon is the head of DevOps at Solovis, creator of badmishka.co, and all around mischievous nerdy guy.