Table of Contents
Chocolatey is a Windows counterpart to the Linux apt package manager or yum package manager. The software offers a CLI-based package installation and management in Windows with the community-maintained package repository.
Chocolatey is a command-line package manager and installer for Windows operating systems. With the NuGet packaging infrastructure and the Windows PowerShell technology at its core, Chocolatey simplifies and automates the process of installing software and keeping it up to date.
Prerequisites
- Windows 7+/Windows 2003+ (including Server Core, but excluding Windows Nano Server).
- .NET Framework 4.x+.
- A user account with administrator privileges.
Install Chocolatey on Windows 7
Chocolatey can be install simply using command line. You can use the Command Prompt (cmd)
or Windows PowerShell to install it. Both installations require an account with administrative shell access.
Method 1: Install Chocolatey via Command Prompt
1️⃣ Search then open Windows Command Prompt as administrator.
2️⃣ Run the following command to install Chocolatey package manager automatically.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
3️⃣ Wait for the installation process to finish to start using Chocolatey. Once done. close then reopen CMD then run choco command to verify it works.
C:\WINDOWS\system32>choco
Chocolatey v2.1.0
Please run 'choco -?' or 'choco <command> -?' for help menu.
Method 2: Install Chocolatey via PowerShell
2️⃣ Search then open Windows PowerShell as administrator.
2️⃣ Run the following commands at once to install Chocolatey package manager automatically.
Set-ExecutionPolicy Bypass -Scope Process -Force
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
#The installation output
Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)
Getting latest version of the Chocolatey package for download.
Not using proxy.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.2.2.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.2.2 to C:\Users\CLOUDP~1\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\CLOUDP~1\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\CLOUDP~1\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
Adding Chocolatey to the profile. This will provide tab completion, refreshenv, etc.
WARNING: Chocolatey profile installed. Reload your profile - type . $profile
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring Chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
How to use Chocolatey
1️⃣ Get the list of Chocolatey commands using choco –help command.
PS C:\> choco --help
This is a listing of all of the different things you can pass to choco.
Options and Switches
-v, --version
Version - Prints out the Chocolatey version.
Commands
* apikey - retrieves, saves or deletes an API key for a particular source
* cache - Manage the local HTTP caches used to store queries (v2.1.0+)
* config - Retrieve and configure config file settings
* export - exports list of currently installed packages
* feature - view and configure choco features
* features - view and configure choco features (alias for feature)
* find - searches remote packages (alias for search)
* help - displays top level help information for choco
* info - retrieves package information. Shorthand for choco search pkgname --exact --verbose
* install - installs packages using configured sources
* list - lists local packages
* new - creates template files for creating a new Chocolatey package
* outdated - retrieves information about packages that are outdated. Similar to upgrade all --noop
* pack - packages nuspec, scripts, and other Chocolatey package resources into a nupkg file
* pin - suppress upgrades for a package
* push - pushes a compiled nupkg to a source
* search - searches remote packages
* setapikey - retrieves, saves or deletes an API key for a particular source (alias for apikey)
* source - view and configure default sources
* sources - view and configure default sources (alias for source)
* template - get information about installed templates
* templates - get information about installed templates (alias for template)
* uninstall - uninstalls a package
* unpackself - re-installs Chocolatey base files
* upgrade - upgrades packages from various sources
2️⃣ Chocolatey allows users to search for a package locally or remotely. Although search is currently an alias for the list command, starting from version 2.0.0, list will work only for local and installed packages. search and find will be used for remote sources as well. For example, to search for Nmap tool:
PS C:\> choco search nmap
Chocolatey v2.2.2
advanced-ip-scanner 2.5.4594.1 [Approved] Downloads cached for licensed users
nmap 7.93.0 [Approved]
2 packages found.
3️⃣ Once you find the app, you can install it automatically as follows:
choco install nmap -y
Chocolatey will check and install all missing dependencies then install the app. You don’t need to do any manual actions because Chocolatey will do it automatically.
PS C:\> choco install nmap -y
Chocolatey v2.2.2
Installing the following packages:
nmap
By installing, you accept licenses for the packages.
Progress: Downloading chocolatey-compatibility.extension 1.0.0... 100%
chocolatey-compatibility.extension v1.0.0 [Approved]
chocolatey-compatibility.extension package files install completed. Performing other installation steps.
Installed/updated chocolatey-compatibility extensions.
The install of chocolatey-compatibility.extension was successful.
Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-compatibility'
Progress: Downloading chocolatey-core.extension 1.4.0... 100%
chocolatey-core.extension v1.4.0 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
Installed/updated chocolatey-core extensions.
The install of chocolatey-core.extension was successful.
Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'
Progress: Downloading autohotkey.install 1.1.37.1... 100%
autohotkey.install v1.1.37.1 [Approved]
autohotkey.install package files install completed. Performing other installation steps.
Installing autohotkey.install...
autohotkey.install has been installed.
AutoHotkey* installed to 'C:\Program Files\AutoHotkey'
AutoHotkey* registered as AutoHotkey
autohotkey.install can be automatically uninstalled.
The install of autohotkey.install was successful.
Software installed as 'exe', install location is likely default.
Progress: Downloading autohotkey 1.1.37.1... 100%
autohotkey v1.1.37.1 [Approved]
autohotkey package files install completed. Performing other installation steps.
The install of autohotkey was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading chocolatey-windowsupdate.extension 1.0.5... 100%
chocolatey-windowsupdate.extension v1.0.5 [Approved]
chocolatey-windowsupdate.extension package files install completed. Performing other installation steps.
Installed/updated chocolatey-windowsupdate extensions.
The install of chocolatey-windowsupdate.extension was successful.
Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-windowsupdate'
Progress: Downloading KB2919442 1.0.20160915... 100%
KB2919442 v1.0.20160915 [Approved]
KB2919442 package files install completed. Performing other installation steps.
Skipping installation because this hotfix only applies to Windows 8.1 and Windows Server 2012 R2.
The install of KB2919442 was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading KB2919355 1.0.20160915... 100%
KB2919355 v1.0.20160915 [Approved]
KB2919355 package files install completed. Performing other installation steps.
Skipping installation because this hotfix only applies to Windows 8.1 and Windows Server 2012 R2.
The install of KB2919355 was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading KB2999226 1.0.20181019... 100%
KB2999226 v1.0.20181019 [Approved] - Possibly broken
KB2999226 package files install completed. Performing other installation steps.
Skipping installation because update KB2999226 does not apply to this operating system (Microsoft Windows 11 Enterprise).
The install of KB2999226 was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading KB3035131 1.0.3... 100%
KB3035131 v1.0.3 [Approved]
KB3035131 package files install completed. Performing other installation steps.
Skipping installation because update KB3035131 does not apply to this operating system (Microsoft Windows 11 Enterprise).
The install of KB3035131 was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading KB3033929 1.0.5... 100%
KB3033929 v1.0.5 [Approved]
KB3033929 package files install completed. Performing other installation steps.
Skipping installation because update KB3033929 does not apply to this operating system (Microsoft Windows 11 Enterprise).
The install of KB3033929 was successful.
Software install location not explicitly set, it could be in package or
default install location of installer.
Progress: Downloading vcredist140 14.36.32532... 100%
vcredist140 v14.36.32532 [Approved]
vcredist140 package files install completed. Performing other installation steps.
Downloading vcredist140-x86
from 'https://download.visualstudio.microsoft.com/download/pr/eaab1f82-787d-4fd7-8c73-f782341a0c63/5365A927487945ECB040E143EA770ADBB296074ECE4021B1D14213BDE538C490/VC_redist.x86.exe'
Progress: 100% - Completed download of C:\Users\CloudPC01\AppData\Local\Temp\chocolatey\vcredist140\14.36.32532\VC_redist.x86.exe (13.2 MB).
Download of VC_redist.x86.exe (13.2 MB) completed.
Hashes match.
Installing vcredist140-x86...
vcredist140-x86 has been installed.
Downloading vcredist140-x64 64 bit
from 'https://download.visualstudio.microsoft.com/download/pr/eaab1f82-787d-4fd7-8c73-f782341a0c63/917C37D816488545B70AFFD77D6E486E4DD27E2ECE63F6BBAAF486B178B2B888/VC_redist.x64.exe'
Progress: 100% - Completed download of C:\Users\CloudPC01\AppData\Local\Temp\chocolatey\vcredist140\14.36.32532\VC_redist.x64.exe (24.18 MB).
Download of VC_redist.x64.exe (24.18 MB) completed.
Hashes match.
Installing vcredist140-x64...
vcredist140-x64 has been installed.
vcredist140 may be able to be automatically uninstalled.
The install of vcredist140 was successful.
Software installed as 'exe', install location is likely default.
Progress: Downloading nmap 7.93... 100%
nmap v7.93.0 [Approved]
nmap package files install completed. Performing other installation steps.
Installing nmap...
nmap has been installed.
nmap may be able to be automatically uninstalled.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The install of nmap was successful.
Software installed to 'C:\Program Files\Npcap'
Chocolatey installed 12/12 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Installed:
- autohotkey v1.1.37.1
- autohotkey.install v1.1.37.1
- chocolatey-compatibility.extension v1.0.0
- chocolatey-core.extension v1.4.0
- chocolatey-windowsupdate.extension v1.0.5
- KB2919355 v1.0.20160915
- KB2919442 v1.0.20160915
- KB2999226 v1.0.20181019
- KB3033929 v1.0.5
- KB3035131 v1.0.3
- nmap v7.93.0
- vcredist140 v14.36.32532
Packages requiring reboot:
- vcredist140 (exit code 3010)
The recent package changes indicate a reboot is necessary.
Please reboot at your earliest convenience.
4️⃣ Use the following syntax to install one or multiple packages at once.
choco install pkg1 pkg2 -y
For example, to install the 7zip package from the default repository, run:
PS C:\WINDOWS\system32> choco install 7zip opera -y
Installing the following packages: 7zip
By installing, you accept licenses for the packages.
Progress: Downloading 7zip.install 22.1... 100%
Progress: Downloading 7zip 22.1... 100%
7zip.install v22.1 [Approved]
7zip.install package files install completed. Performing other installation steps.
Installing 64 bit version
Installing 7zip.install...
7zip.install has been installed.
7zip installed to 'C:\Program Files\7-Zip'
Added C:\ProgramData\chocolatey\bin\7z.exe shim pointed to 'c:\program files\7-zip\7z.exe'.
7zip.install can be automatically uninstalled.
The install of 7zip.install was successful.
Software installed to 'C:\Program Files\7-Zip\'
7zip v22.1 [Approved]
7zip package files install completed.
5️⃣ If you’ve not familiar with command line. The GUI app is available in the Chocolatey community repository and allows users to perform most of the tasks available using the CLI. The GUI simplifies the process for users not accustomed to using the CLI.
To install the Chocolatey GUI, run the below command:
choco install chocolateygui -y
6️⃣ Chocolatey supports upgrades the installed apps. The upgrade command upgrades the specified package or list of packages. If the package is not installed, upgrade installs it instead.
choco upgrade 7zip -y
PS C:\> choco upgrade 7zip -y
Chocolatey v2.2.2
Upgrading the following packages:
7zip
By upgrading, you accept licenses for the packages.
7zip is not installed. Installing...
Progress: Downloading 7zip 23.1.0... 100%
7zip v23.1.0 [Approved]
7zip package files upgrade completed. Performing other installation steps.
The upgrade of 7zip was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\7zip'
Chocolatey upgraded 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
In case if you want to update all the installed apps using Chocolatey package manger. Add the all flag to the upgrade command to update all packages at once.
choco upgrade all -y