Automating Windows Setup via Chocolatey

When you’re a software professional, 1 thing you must’ve dreaded is setting up a new Windows machine (as in a development environment). This might be since doing so needs either downloading multiple .MSI / .EXE files of the required applications or usi…


This content originally appeared on DEV Community and was authored by Vinay Hegde

When you're a software professional, 1 thing you must've dreaded is setting up a new Windows machine (as in a development environment). This might be since doing so needs either downloading multiple .MSI / .EXE files of the required applications or using the Microsoft App Store (personally I believe it's a little off the mark compared to the Linux/MacOS).

It's also compounded by the fact Windows systems are regarded relatively volatile so we never re-touch/re-configure applications once installed. You also must've surely wondered why Windows trails Linux/Mac OS when it comes to Command Line. Agreed, PowerShell changes most of that but learning a new syntax can be a little harrowing.

What if I told you this could be solved permanently via CLI? Enter Chocolatey to the rescue.

Chocolatey is a package manager specifically designed for Windows systems to solve these very problems. Consider it equivalent to apt-get, dnf or brew giving you sufficient power to work with Windows, so much that you might never go back to tedious manual methods again.

Prerequisites:

  • Understanding how Powershell policies work such as Set-ExecutionPolicy, here is an excellent page to get you started.
  • From the Chocolatey official page
    • Windows 7+ / Windows Server 2003+
    • PowerShell v2+ (Not PowerShell Core, minimum is v3)
    • .NET Framework 4+ (installation attempts to install .NET 4.0 if absent, minimum is v4.5 due to TLS v1.2)
  • Excitement to learn something new and preferably a cup of tea/coffee.

Steps:

  • Follow this link to install Chocolatey.
  • If you get an error like below, then install PowerShell v7.3 using these steps
'Get-ExecutionPolicy' is not recognized as the name of a cmdlet
  • If you've successfully installed Chocolatey, you should now be able to run choco --version.

And that's it if you prefer the vanilla install but if you like to dive deeper, you'll quickly realize a few concerns.

  • How can we install specific versions of software as needed?
  • What if we wanted to install multiple applications in 1 go, uninterrupted?
  • Can we rollout to multiple machines? (Note: some features for this point may need Chocolatey enterprise, please read the documentation as per your use-cases)

Lets answer the 1st two questions.

Number 1 is pretty simple, you just execute choco install vlc={version} and relax. Number 2 can be a little bit tricky but a handy way is to use the Packages.config which is an XML file containing the list of applications we want to install.

Now the command becomes choco install {path-to-file.config} --yes

Here is a sample that you can use or create one/more referring it as per your requirements. You can also keep it under version control to have an audit for changes.

Result?

On a fresh Windows 10 machine, it took me ~35 minutes to install everything, including time to download software as well. Then I use my own curated .dotfiles for certain tools to finish the development setup so I hope this guide helps you save time/effort as well.

What are the ways you use to setup Windows environments?


This content originally appeared on DEV Community and was authored by Vinay Hegde


Print Share Comment Cite Upload Translate Updates
APA

Vinay Hegde | Sciencx (2021-07-25T17:21:10+00:00) Automating Windows Setup via Chocolatey. Retrieved from https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/

MLA
" » Automating Windows Setup via Chocolatey." Vinay Hegde | Sciencx - Sunday July 25, 2021, https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/
HARVARD
Vinay Hegde | Sciencx Sunday July 25, 2021 » Automating Windows Setup via Chocolatey., viewed ,<https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/>
VANCOUVER
Vinay Hegde | Sciencx - » Automating Windows Setup via Chocolatey. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/
CHICAGO
" » Automating Windows Setup via Chocolatey." Vinay Hegde | Sciencx - Accessed . https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/
IEEE
" » Automating Windows Setup via Chocolatey." Vinay Hegde | Sciencx [Online]. Available: https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/. [Accessed: ]
rf:citation
» Automating Windows Setup via Chocolatey | Vinay Hegde | Sciencx | https://www.scien.cx/2021/07/25/automating-windows-setup-via-chocolatey/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.