Automating Windows environments’ setup with Boxstarter and Chocolatey packages

Cesar De la Torre

image

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:

BoxStarter_Script.txt

Set-ExplorerOptions -showProtectedOSFiles -showFileExtensions

Enable-RemoteDesktop

cinst adobereader

cinst google-chrome-x64

cinst imageresizerapp

cinst skype

cinst f.lux 

cinst WindowsLiveWriter

cinst sysinternals

cinst git

cinst git.install

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.

image

You can get the URL (permalink) to your script by pressing the “Raw” button, so you’ll get something like:

https://gist.githubusercontent.com/CESARDELATORRE/2c330905cd96eXXXXX/BoxStarter_CESARDL_Script.txt

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:

START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/CESARDELATORRE/2c3b3e_YOUR_URL_a71e/BoxStarter_Script.txt

image

It will download BoxStarter thru INTERNET EXPLORER and Click-Once deployment and start executing the setup Process:

image

You can see below how it is installing Google Chrome, for instance:

image

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:

https://chocolatey.org/packages

image

For instance, this is the Office 365 Pro Plus package:

https://chocolatey.org/packages/Office365ProPlus

You can add it to your list by writing:

cinst office365proplus

Or for Visual Studio 2013 Ultimate RTM:

https://chocolatey.org/packages/VisualStudio2013Ultimate 

(Check this URL to install optional features in VS 2013)

cinst visualstudio2013ultimate

or with optional features:

cinst VisualStudio2013Ultimate -InstallArguments "Blend LightSwitch OfficeDeveloperTools SQL WebTools Win8SDK WindowsPhone80"

Resources

For deeper info, check the following resources:

http://www.boxstarter.org/

http://boxstarter.org/WhyBoxstarter

https://chocolatey.org/

ScottHa 2014 Tool list, including BoxStarter, etc. http://www.hanselman.com/blog/ScottHanselmans2014UltimateDeveloperAndPowerUsersToolListForWindows.aspx

0 comments

Discussion is closed.

Feedback usabilla icon