Windows 8 and 8.1 Forums

Chocolatey - Install Apps from Command Line

  1. #1
    Chocolatey - Install Apps from Command Line

    Chocolatey - Install Apps from Command Line
    How to Use Chocolatey Package Manager to Install Desktop Apps in Windows
    Published by Kari is offline
    30 Oct 2014
    Default Chocolatey - Install Apps from Command Line

    Published by

    Kari's Avatar
    Old geek, new tricks

    Join Date: Jul 2009
    Location: A Finnish ex-pat in Leipzig, Germany
    Posts: 1,452

    How to Use Chocolatey Package Manager to Install Desktop Apps in Windows

    information   Information
    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.
    (Quote from Package manager - Wikipedia, the free encyclopedia.)

    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.

    Chocolatey changes 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:
    choco install Chrome, Opera, Firefox, AdobeReader, WinRAR
    After sending the command to the system with Enter, user can take a break, all programs will install silently in the background. Later on user could check if any updates are available again with one command which then updates any packages (applications) which are not up to date, At the moment of writing this tutorial the Chocolatey repository has 2,311 packages ready to be installed. The repository only contains Windows desktop applications, Modern applications are not supported.

    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   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.

    Chocolatey - Install Apps from Command Line Step One Chocolatey - Install Apps from Command Line
    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:

    Click image for larger version

    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 install Chocolatey we need to set an unrestricted execution policy. I recommend that after you have installed Chocolatey you change the policy to RemoteSigned.

    To change the execution policy give the command Set-Executionpolicy unrestricted and hit Enter, accept the policy change with Yes:

    Click image for larger version

    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:
    iex ((new-object net.webclient).DownloadString(''))

    Click image for larger version

    1.3 B) (Command Prompt users only.)

    If you are using an elevated Command Prompt, the command is:
    @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString(''))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

    Click image for larger version

    1.4) It can take a moment but finally you have Chocolatey installed on your system:

    Click image for larger version

    Chocolatey - Install Apps from Command Line Step Two Chocolatey - Install Apps from Command Line
    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:

    Click image for larger version

    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:

    Click image for larger version

    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*:

    Click image for larger version

    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:

    Click image for larger version

    After a while Chocolatey reports that Adobe Reader is now installed:

    Click image for larger version

    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:
    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 (;) 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:

    Click image for larger version

    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   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.


  2. #1

    Posts : 341
    Win8.1 64bit, Windows 10 TP on VMWare Player

    An interesting piece of software, Kari.

    Can I check a couple of things please:

    Firstly, it looks like if you choose to use a command prompt to install the program, it works through powershell. Is it also the case that if you use the program via a command prompt it will also need to work through powershell? I'm asking because I don't have powershell switched on currently.

    Secondly it's great that the program installs without PUPs, but does it follow the default installation otherwise? What I mean is that there are some programs where the default will add a desktop shortcut, a start menu entry etc. unless you untick the option. With individual installs I can choose when to add a shortcut and when not, and to avoid adding unnecessary things into the startup menu. would I have to tidy these things up afterwards if I use chocolatey?


      My System SpecsSystem Spec

  3. #2

    A Finnish ex-pat in Leipzig, Germany
    Posts : 1,452
    Windows 8.1 Pro with Media Center

    PowerShell is a built-in native system component of Windows 8 and cannot be disabled or uninstalled. it's always there. Chocolatey installer runs through PowerShell even when launched from Command Prompt, later when used from Command prompt it does not need PowerShell.

    All installs are done with default settings. The PowerShell OneGet which will be natively included in Windows 10 is going to have more install options.

      My System SpecsSystem Spec

  4. #3

    Posts : 341
    Win8.1 64bit, Windows 10 TP on VMWare Player

    Thanks Kari. Think I will have a look at this when I get my new hard drive installed.

    I had a look at the OneGet tutorial. It looks like OneGet will remove the need to use chocolatey in the commands (no need to type choco install ... etc.).

    And just read that Windows 10 will be offered free for a while, so may get to try that sometime too.
      My System SpecsSystem Spec

Chocolatey - Install Apps from Command Line
Related Threads
Hello all, After taking some time to learn about CyberGhost, I finally took the plunge last year & bought a subscription. I'm happy with the service but, recently I've decided to use it in a more productive fashion. I'd like to set scripts for command line functionality. According to...
Hi! My apologies if this is the wrong forum to post in, but it seemed like the best fit. So I'm trying to get a bat file together with power settings that I want to apply. But I'm running into an issue. For some reason, the power button and lid close actions wont change. Here is the relevant...
DOS Command Line in General Support
Hi there- Just reorganising my Library and for reasons I won't bore you with, need to do some mass amendments to Filenames to get rid of extraneous Info as I'm tight on Space. So, for instance, I have a Folder (DIRectory) with one hundred PDF, Mobi, RAR, ZIP, CBR and CBZ files in it all with...
Command Line Reference for Windows 8 and 8.1 A command prompt is an entry point for typing computer commands in the Command Prompt window. By typing commands at the command prompt, you can perform tasks on your computer without using the Windows graphical interface. This tutorial will...
Or if there is a script for AutoHotkey? Thanks.
New Command Line YouTube Player And Downloader With Local Playlists Support: mps-youtube ~ Web Upd8: Ubuntu / Linux blog
Hello, I Have Installed a Web App That Support IE7 Only, Means It display Bad on IE8,9,10. So I would like to know if There is a Command Line to Attach it to the IE Shortcut that Open the Web App in IE7 Computability mode, I'm Desperate to know a solution. Note: I'm Using Windows8 Pro with IE...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook