chocolatey logo

You guys know about Chocolatey? It’s a package manager for Windows. If you are familiar with package managers on Linux, then you already know how useful a package manager can be to simplify software installation and maintenance. Chocolatey works pretty much just like you would expect if you have used yum or apt-get on Linux. Chocolatey maintains a large repository of mostly open-source software for Windows. Once Chocolatey is installed on a Windows PC, you can install most common open-source and free software with a single command! Or install multiple products with a single command. Chocolatey, by default, always gets the latest version of applications and you can schedule it with Scheduled Tasks in Windows to keep software up-to-date!

You can install Chocolatey just by running this command in Windows CLI (use an elevated CMD prompt):

@"%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://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

chocolatey

After installing Chocolatey, you will need to open a new CMD promopt (which you can do with the “start” command in Windows CLI).

With Chocolatey installed you can now install software with the command “choco install” followed by the package name or names. For example to install Google Chrome, 7-zip, R, and R Studio with one command use this:

choco install googlechrome 7zip r.package r.studio

You can search Chocolatey for the correct package name with this command:

choco list winscp

This command find all the packages releated to “winscp.”

chocolatey

“choco list” will show every package in Chocolatey. Fair warninig, it’s alot of stuff and you are going to be waiting a few minutes for the command to return results–5407 packages as of this writing.

“choco list -local” will show just the packages that have been installed with Chocolatey.

“choco upgrade all” will update all software that has been installed with Chocolatey. If it wasn’t installed with Chocolatey it won’t be updated by this command.

You would think that adding “-a” or “-y” to the end of a choco command would suppress the confirmation prompt, but that doesn’t always work. Enabling “allowGlobalConfirmation” will fix this:

choco feature enable -n allowGlobalConfirmation

Create a scheduled task in Windows to run this upgrade command to update software automatically!

choco upgrade all -a  

You can combine Chocolatey with psexec to push software to remote network PCs! First use psexec to install Chocolatey to the remote PC with this command, substituting in the correct hostname or IP address:

psexec64 -accepteula \\HOSTNAME cmd /c "@"%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://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"" 2>nul

After Chocolatey is installed to your remote PC, you can push software to that PC with Chocolatey and psexec:

psexec64 -accepteula \\HOSTNAME cmd /c "choco install googlechrome -a"

In addition to install and upgrade, you can also uninstall:

choco uninstall googlechrome -a  

The commands can get quite long, especially when used with psexec. Here is a tool that can be used to generate choco commands.






choco install %software% -a

psexec64 -accepteula \\%host% cmd /c "choco install %software% -a"

Here is a version of the tool that can be bookmarked:
https://hull1.com/choco

Searching for package names in the CLI is probably faster, but you can also get a full list of package names here: https://chocolatey.org/packages

Here are a few of the best ones:

  • googlechrome
  • firefox
  • 7zip
  • r.package
  • r.studio
  • winscp
  • putty
  • mendeley
  • foxitreader
  • gimp
  • libreoffice
  • keepass
  • vlc
  • notepadplusplus
  • texstudio
  • miktex
  • zoom
  • filezilla
  • cygwin
  • git
  • anaconda3

Further Reading:
https://chocolatey.org/

https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

https://hull1.com/choco

https://hull1.com/software_deployment/2020/08/10/scheduled-choco-updates.html