Chocolatey Install Windows

Chocolatey Install Windows Average ratng: 7,8/10 874 votes

Most Windows users don’t pay much attention to how desktop programs are installed on their system. For years we’ve been trained to seek out a website, download an EXE or MSI file, and then click, click, click our way through the installation.

It’s an easy method, but it’s also time consuming because of the manual interaction.

Chocolatey was born out of providing automation for Windows and doing that with packages, packages that could surround an installer but didn't necessarily need to. The Chocolatey install scripts use the Chocolatey package (a nupkg file itself) to be installed and upgraded as just another package. There is a package manager for Windows that works well and integrates with Puppet: Chocolatey. Let’s explore how to use Chocolatey and how it works with Puppet. Microsoft has a package manager, OneGet, but OneGet new enough that it’s not installed by default in PeopleSoft-certified versions of Windows. How can the answer be improved?

A burgeoning project called Chocolatey wants to make it easy to install desktop apps without having to click through an interminable number of installation windows.

What is Chocolatey?

Chocolatey is a command line application installer for Windows based on a developer-centric package manager called NuGet. Unlike manual installations, Chocolatey adds, updates, and uninstalls programs in the background requiring very little user interaction.

Chocolatey has its own package feed that is created and maintained by the project’s community members.

Behind the scenes, most Chocolatey packages simply download a program’s official executable and install it without any further interaction from the user.

You lost me at “command line”

No, wait, hear me out!

Getting new programs the old fashioned way is very easy, but manual installs are also inefficient. Wouldn’t you rather spend your time checking out the latest cat videos on YouTube while your PC goes about installing programs by itself?

That’s the promise of Chocolatey. If the program has any dependencies, such as the .NET framework, Chocolatey will install those too.

Chocolatey can also take care of multiple program installations.

Imagine cracking open a new PC, downloading Chocolatey and then typing a one-line command to install all the programs you’d like to have on your new machine. That's what Chocolatey does.

Installing Chocolatey

Getting Chocolatey onto your system is very simple since the commands can be copied and pasted into your command prompt from Chocolatey.org. To start, you need to open an elevated command prompt.

To do this in Windows 8.1, click on the Start button and go to the all apps screen. Under the Windows System heading find Command Prompt, right click-it and select Run as administrator. When the User Account Control window opens, authorize it by clicking Yes.

A command prompt window should open with something like C:WINDOWSsystem32.

Next, visit Chocolatey.org and copy the first box. At this writing, the commands were:

Paste it into the prompt, press Enter and your PC will take care of the rest.

Usually doing a copy and paste of commands is not advisable, but in this case it’s just fine.

So you can rest easier, let’s break the instructions down a little bit: These commands are telling your PC to launch PowerShell and don’t load any custom profiles a power user might have. Next, it tells Windows to set the execution policy to unrestricted to allow any PowerShell script to be run and then download and run the Chocolatey install script.

Chocolatey basics

Installing programs Chocolatey style

Once you’ve got Chocolatey up and running, it’s time to start installing programs. Open an administrative command prompt again and type cinst [program name].If you wanted to install VLC you’d type:

Pretty easy, right? The trick is that you need to know the exact name Chocolatey uses for each program. You can’t just type Chrome or Google-Chrome and expect Chocolatey to figure it out.

To find the names of programs, you can try playing around on the command line with the trial and error method (which works more often than you’d think). If you don't have that kind of time, search Chocolatey.org’s online package catalog for programs. You can also search for packages right on the command line:

Multiple installs

There are two ways to install multiple programs in one sitting with Chocolatey. The first is to type multiple arguments into the command line. If you wanted to install VLC, GIMP, and Firefox you’d type:

For much larger batches of programs, however, you’re better off creating an XML document with a .config file extension and formatting it like so:

That basic document structure can include as many programs as you like, and can even include alternative sources other than Chocolatey’s community feed. For a more thorough tutorial on creating a multiple install file, check out developerFusion.

Uninstalling and updating

Updating installed programs via Chocolatey is simple too. Type cup [program name] into an administrative command. To update DosBox, for example, type:

You can also update all your programs by typing cup all. If your package is using an alternative source other than the main Chocolatey package feed, you can type:

Uninstalling a package is a little different. Going back to our example, you'd type the following to uninstall DosBox:

On the next page, we'll cover standardized commands and security concerns.

Installing and upgrading software has always been a tedious task. For end users, you begin with getting the software followed by downloading and installation.

It is a seemingly smoother process on Linux via the command-line (think apt-get), where few commands install or update software (of course, you still need to find what you need to install). This command line interface is now available for Windows users via the oddly named Chocolatey package manager.

Chocolatey NuGet?

The many options for Windows package or software management can be confusing. NuGet is a package management system for developers — that is, it handles packages and references for projects, thus allowing the developer to concentrate on code.

While NuGet handles packages, Chocolatey handles applications at a system level. So, you would use Chocolatey to install an application such as Puppet on your development machine. It appears Chocolatey is becoming the de facto standard for Windows package and dependency management, but it still is not a standard Windows component.

Getting Chocolatey

Chocolatey uses PowerShell along with the NuGet packaging format. (You'll need to set up PowerShell before reaching for Chocolatey.) To install Chocolatey, open a command prompt and enter the following command:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command 'iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))' && SET PATH=%PATH%;%systemdrive%chocolateybin

  • -NoProfile: This switch suppresses custom profiles to avoid installation conflicts.
  • -ExecutionPolicy: You're downloading code via the internet, so execution policy is set to unrestricted to allow the download.
  • -Command: This is the download command of Chocolatey. The command is enclosed in double quotes.
  • SET PATH: This adds Chocolatey to the system path, so you can run it from anywhere on the system.

Chocolatey can be installed via NuGet, and it is available as a NuGet package. Once installed, you can use the help switch to get an idea of how to use Chocolatey. Figure A shows a portion of the information returned by the help command (chocolatey /?).

Figure A

Using the help command line switch to get details on Chocolatey usage.

Chocolatey goodness

With Chocolatey installed, you can use it to install software on your machine via two commands:

  • cinst (chocolatey install): This command is used to install software packages. The install command has a number of additional options and command line switches; a complete list is available online.
  • cuninst (chocolatey uninstall): This command is used to uninstall software packages. It currently supports one optional command line switch to specify the version to uninstall.

The Chocolatey sites provides a gallery of currently available software, and you can easily add your own packages (this requires site registration). The following command installs Firefox on my machine:

cinst Firefox

This kicks off a silent install, so there's no need to do anything else. Figure B shows the results of the command.

Figure B

The following command will remove Firefox from your system:

cuninst Firefox

Once software is installed, you will need or want to keep it updated. The update (or cup) command allows you to quickly update an existing package to the latest version if there is one. The following command(s) demonstrate updating our Firefox installation:

chocolatey update Firefox - or - cup Firefox

Chocolatey Install Windows

The chocolatey command can be shortened to choco, so the previously listed update command could be typed as:

choco update Firefox

Maintaining software is the gist of Chocolatey, but basic installs are only the tip of the iceberg, as it offers more advanced commands for working with Windows components and settings, as well as integrating with Ruby Gems, Python, and more. The WindowsFeatures option allows you to install Windows options via the Deployment Image Servicing and Management tool on the local machine. The following command installs the Telnet client:

choco WindowsFeatures TelnetClient

Windows

The online documentation provides more information on the WindowsFeatures option and everything else available.

Tasks like setting a new machine (installing all necessary software) come to mind with a tool like Chocolatey. With Chocolatey installed on your machine, you can use it and its commands with scripts to streamline updates or installations. In addition, there are add-on tools such as Boxstarter that use Chocolatey packages to set up new environments. You can browse the online gallery to get an idea of what else is available via Chocolatey. In addition, the list and search commands can be used to get a list of available software via the command line. The following command lists everything available:

choco list

The next command finds everything with 'ftp' in its name:

choco list ftp - or - choco search ftp

Final thoughts

While Chocolatey is not a tool for everyday users, it is a great utility for techies who want a quick and dirty way to install software. Since first discovering Chocolatey, I have jumped on the bandwagon, and I have used it to keep my collection of machines up and running.

Chocolatey is hosted on GitHub, so you can contribute to its development if inclined. Its Google Group is a great resource as well.

I have not seen official announcements from Microsoft about Chocolatey, though the company's recent unveiling of OneGet shows that it's embracing the package manager. Chocolatey is currently the only repository for OneGet (I am sure more will follow).

Are you using Chocolatey? If so, do you think it's a simpler approach to software installation? If not, do you plan to give it a try? Let us know in the discussion.