How to Use Chocolatey Package Manager to Install Desktop Apps in Windows
Information
(Quote from Package manager - Wikipedia, the free encyclopedia.)A package manager is a collection of software tools that automates the process of installing, upgrading, configuring, and removing software packages for a computer's operating system in a consistent manner.
Linux users know the package manager apt-get which installs for instance Google Chrome browser to Ubuntu with a simple command sudo apt-get install google-chrome-stable. Advanced Windows users, mostly system and network administrators know the NET Framework package manager NuGet. As good as NuGet is it has been a bit too complicated to interest normal users.
Chocolateychanges this. It is an easy to setup and use excellent Windows package manager which uses the NuGet packaging infrastructure. It collects the application installers to a so called repository, from where a user can install any package (application) with one simple command. For instance when Chocolatey is installed and set up, the user could install the latest versions of three browsers, a PDF reader and a file compression tool with this simple command:
Code:
choco install Chrome, Opera, Firefox, AdobeReader, WinRAR
This tutorial will show you how to install and set up Chocolatey and gives you the basic commands to start using it. If you have any concerns, questions or issues or need help with advanced features not covered in this tutorial, feel free to post in this tutorial thread, I will try my best to answer you.
Note
I am using the Windows native PowerShell for this tutorial. I recommend using it but if you are more familiar with traditional Command Prompt, you can do all this with it, too. Notice that regardless if you use PowerShell or Command Prompt, it must be elevated.
Step One
Download and set up Chocolatey
1.1) (Command Prompt users, see this tutorial for opening an elevated Command Prompt, jump to step 1.3 B. )
Open an elevated PowerShell. It is irrelevant if you prefer the classic PowerShell or its "pimped" big brother PowerShell ISE (PowerShell Integrated Scripting Environment). My choice is as always the PowerShell ISE. In any case, both versions can be found in folder C:\Windows\System32\WindowsPowerShell\v1.0\. Right click the one you prefer and select Run as administrator:
1.2) (PowerShell only, Command Prompt users please jump to step 1.3 B.)
An execution policy determines which scripts can be run in PowerShell. We want to add the Chocolatey repository with its 2,300+ packages. In order to be able to do that we have to have unrestricted rights to run PowerShell scripts. These rights are determined by Execution Policy. There are four level of execution policy rights:
- Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode
- AllSigned - Only scripts signed by a trusted publisher can be run
- RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run
- Unrestricted - No restrictions; all Windows PowerShell scripts can be run
To change the execution policy give the command Set-Executionpolicy unrestricted and hit Enter, accept the policy change with Yes:
1.3 A) (For PowerShell users, Command Prompt users please see step 1.3 B.)
We are ready to install Chocolatey. Type the following command, exactly as written here or use copy & paste:
Code:
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
1.3 B) (Command Prompt users only.)
If you are using an elevated Command Prompt, the command is:
Code:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
1.4) It can take a moment but finally you have Chocolatey installed on your system:
Step Two
Use Chocolatey
2.1) First you need of course to check if the package (application) you want to install is available. You can get a list of all available packets with command choco list. As there are already over 2,300 packages available, viewing the complete list in PowerShell or Command Prompt is not practical. You can "pipe" the output to a pop-up window in grid form adding the pipe symbol ('|') and argument Out-GridView (only in PowerShell). The command would now be choco list | Out-GridView. This opens a pop-up with a complete list of available packages:
2.2) The GridView output cannot be saved. If you want to save the list or if you are using Command Prompt which does not support the GridView, you can "pipe" the output to clipboard and paste it in Notepad or any text editor and word processor. To pipe the list output to clipboard use command choco list | clip, open Notepad and paste:
2.3) You can of course also search for a certain package by its name, or use wildcard ('*') in searches. Here I try to find package Adobe Reader searching all packages where the word Adobe appears in the name or the description of the package, the command is choco list Adobe*:
2.4) Package for Adobe Reader was found, let's install it. Command is choco install AdobeReader -verbose. The -verbose switch is not obligatory; I like to use it as it shows on screen everything that happens. Without it the installation does not show any messages, only reports when it's done:
After a while Chocolatey reports that Adobe Reader is now installed:
2.5) OK, that was simple. How about installing multiple packages at once? No problem. First use list command to see if the package (application) you need is available, then simply separate all packages with comma to install all at once. The following command installs three browsers with one command:
Code:
choco install GoogleChrome, Firefox, Opera
(Please notice: separating multiple app packages with comma only works in PowerShell. If you are running Chocolatey from Command Prompt, use semicolon [noparse]([/noparse] as separator.)
Piece of cake
2.6) Without me even noticing it, I can see that the Adobe Reader, Chrome, Firefox and Opera shortcuts have appeared on my desktop:
What's best is that using Chocolatey I don't have to think about being careful all the time and controlling that an app I want to install does not install a toolbar or two or some adware or whatnot. Using Chocolatey I only get what I want to, nothing else.
Tip
For advanced users:
Chocolatey is an excellent tool when you are customizing your Windows images. Interrupt the Windows installation to enter Audit Mode before any user accounts have been created, use Chocolatey to install all apps you want your image to contain, finally sysprep and generalize the image. Done.
Using this image to install Windows you have now all your apps installed, included in Windows image.
Chocolatey is an excellent tool when you are customizing your Windows images. Interrupt the Windows installation to enter Audit Mode before any user accounts have been created, use Chocolatey to install all apps you want your image to contain, finally sysprep and generalize the image. Done.
Using this image to install Windows you have now all your apps installed, included in Windows image.
Kari
Attachments
Last edited by a moderator: