Automating Windows environments’ setup with Boxstarter and Chocolatey packages
Talking last week with Scott Hanselman he showed me in his laptop some cool stuff which is very useful for me as I usually need to re-install my machines pretty often due to the release of new betas and the fact that I prefer to start with clean machines whenever I can. And you know, every time you have a new machine or .VHD, you need to re-install a lot of different tools and apps. It is not just about Visual Studio and Office, and sometimes you forget the list of all the apps you need.
So, in a different page, I usually use .VHDX to boot Windows natively (Check this blog post “Booting Windows 8.1 Update natively from a .VHDX image” that I wrote) and it is very convenient as I have like rollback Windows images so I can come back to a baseline, but in any case, after going back to a previous baseline the .VHDX image will usually still have to have quite a few programs to be re-installed manually, like Adobe PDF Reader, Chrome, fiddler, Live Blog Writer, etc. Even more, I might need to install different physical machines so they have different .VHDs to set up…
This is when this stuff that Scott was telling me comes to action, so you can install a list of your most common programs/apps for your Windows machine in an automated way thanks to Boxstarter and Chocolatey packages. Chocolatey packages are nothing but a PowerShell script wrapped as a Nuget package per application that I want to install.
Basically, with Boxstarter you have repeatable, reboot resilient Windows environment installations made easy using Chocolatey packages.
Bottom line, I just have to run BoxStarter by providing my applications’ list and all the software I require will be installed in an automated way!
Here are the steps I followed.
Step 1 – Compose my installation script
You could directly provide the package/application to be installed directly in the URL, like in the following line in the console command prompt:
START http://boxstarter.org/package/skype,fiddler4 (or directly putting the URL in IE with no “START”, Note that this will not work on Chrome or Firefox unless you have a "Click-Once" extension)
But as soon as you have quite a few applications to be installed and with custom setup, you might want to have an installation script, so the following procedure is a better way.
This is simply a text file (.txt) where you can specify Windows configuration plus all the applications you want to install. The following is part of my own installation script:
Set-ExplorerOptions -showProtectedOSFiles -showFileExtensions
cinst Microsoft-Hyper-V-All -source windowsFeatures
cinst IIS-WebServerRole -source windowsfeatures
But rather than just storing that .TXT file somewhere in a drive or USB pen drive, so it is a risk as I could lose it, what I’m doing is to store that .TXT file online as a Gist in GitHub, so it is always available to me when using BoxStarter (since I need Internet Access in any case). You can create your own Gist in your GitHub account, it is super simple, as shown below.
You can get the URL (permalink) to your script by pressing the “Raw” button, so you’ll get something like:
That is the URL of your script you need to provide to BoxStarter in order to install your applications.
IMPORTANT: Take into account that whenever you change the content of your GIST .txt file, the URL (permalink) will change, since you have a different URL per versión. So, if you change the list, you NEED to get the new URL.
Step 2 – Run the Script
So! here is how you run BoxStarter and you get all your software installed!
Execute the following command (specifying your own script .TXT file), in a Windows Console:
It will download BoxStarter thru INTERNET EXPLORER and Click-Once deployment and start executing the setup Process:
You can see below how it is installing Google Chrome, for instance:
What applications are available as Chocolatey packages?
Like I said, you install the applications thru Chocolatey packages which are nothing but a PowerShell script wrapped as a Nuget package per application that I want to install. Sure, you can create your own packages, but usually you’d like to go on the fast lane and use the already published packages. There are many available already. You can check the list out right here:
For instance, this is the Office 365 Pro Plus package:
You can add it to your list by writing:
Or for Visual Studio 2013 Ultimate RTM:
(Check this URL to install optional features in VS 2013)
or with optional features:
cinst VisualStudio2013Ultimate -InstallArguments "Blend LightSwitch OfficeDeveloperTools SQL WebTools Win8SDK WindowsPhone80"
For deeper info, check the following resources:
ScottHa 2014 Tool list, including BoxStarter, etc. http://www.hanselman.com/blog/ScottHanselmans2014UltimateDeveloperAndPowerUsersToolListForWindows.aspx