When ever I have to start a fresh computer or start working at a client. I used to spend an abundance of time installing software just to get started with the necessities.
At some point I stumbled on chocolatey, which just made my life so much easier! Chocolatey is a package management tool for windows that makes it possible to install just about any program from your command line (cli).
How does chocolatey work?
I’m so happy you asked! To understand how chocolatey work one simply needs to go to a specific application that they want to install and read the information there – everything is transparent.
Installing an application using chocolatey
Let’s take an example; say that I want to install vscode – I use that as my preferred IDE.
Previously I would go to the website https://code.visualstudio.com/, download the app click through the installation and then voila – 5-10 minutes laters it would be installed.
Now that I have chocolatey install I simply need to open a cli with admin rights and then type:
choco install [package-name]
To install vscode using chocolately, then type:
choco install vscode --yes
Now visual studio code will be installed automatically. The “–yes” makes sure that I do not need to interact with the installation.
How do I know the name of the package?
Again a great question! Chocolatey comes with a pretty cool ability to search directly from the command-line.
choco search vscode
Will (as of this moment) give you a list of 72 packages. Here you can see that if you want to install extensions for vscode you can also do that using chocolatey. Let’s install the python extension for vs code:
choco install vscode-python
How to install chocolatey?
And now you might think that I still need to go to their website, download – go through the tedious install wizards and wait for it to install. Nope! I’ve got you covered! Depending on whether you prefer powershell or cmd you can do either of the following – just remember to start the application with admin rights:
- Click the Start menu button
- Type powershell
- Right-click Windows Powershell and choose Run as Administrator
- Copy and paste the code below to install chocolatey package manager for windows.
- Answer Yes when prompted
#powershell Set-ExecutionPolicy Bypass -Scope Process -Force; ` iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
To install chocolatey using Command Prompt, repeat the same steps as above but instead of powershell use cmd, and the following snippet (It will actually be using powershell, however, I have tried not having access to powershell – which is why I include this as well):
#cmd @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Upgrading software using chocolatey
Ever so often a new version software producers launches a new version of their software, which in general is great – I love new features and stuff! However, when I have 5-10 applications or so that are nagging me to be updated – it can be tiresome, especially when some of these does not handle the entire update themselves. Chocolatey to the resuce!
choco upgrade [package-name]
This will upgrade the specified package. You can even upgrade chocolatey this way. If you want to upgrade all your applications you can use:
choco upgrade all
This will upgrade all your packages! Find more cool commands on https://chocolatey.org/docs/commands-reference