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 a platforms such as Windows, 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 app store forgot to add for your desktop.
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, 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 multiples times or 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.
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 a the package manager for Windows.
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’))
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 chocolate to install programs that folder based like PHP or MySQL to install 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 to the bin root folder to use c:.
Type or copy $env:ChocolateyInstall = “c:optchocolatey”; into Powershell and hit enter.
PS C:> $env:ChocolateyInstall = "c:optchocolatey";
Type or copy $env:ChocolateyBinRoot = “c:optchocolatey”; into Powershell and hit enter.
PS C:> $env:ChocolateyBinRoot = "c:optchocolatey";
Copy the Chocolatey install code into Powershell and then hit enter.
PS C:> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
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:usersmhernDesktoppackages.txt into Powershell. Replace “mhern” with the name of your user folder on Windows. Hit enter.
PS C:> choco list > c:usersmhernDesktoppackages.txt
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
Type choco upgrade chocolatey into Powershell and hit enter.
PS C:> choco upgrade chocolatey
To uninstall a package, use the uininstall command.
Type choco uninstall GoogleChrome into Powershell and hit enter.
PS C:> choco uninstall GoogleChrome
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.
I supported Chocolatey’s kickstarter campaign.
About the author
Michael Herndon is the head of DevOps at Solovis, creator of badmishka.co, and all around mischievous nerdy guy.