What have you got on Your Box?

Do you know what software you have installed on your box?

We've been working over the last few months on a completely awesome demo called DinnerNow.NET. The Demo showcases many newly released Microsoft technologies including Cardspace, WCF, WF and Windows PowerShell.

One problem we constantly faced was people trying to load the demo on their machines but not having all the pre-requisite components installed or configured to build and run the demo. (Even though we provide a readme). What was needed was a fool(ish) proof way to figure out if the machine was ready.

DinnerNow.NET requires, .NET Framework 3.0, Visual Studio 2005, LINQ, AJAX, AJAX Futures, MSMQ, IIS7, SQL Server 2005 Express, Windows PowerShell (with execution policy set), WCF Extensions for Visual Studio, WF Extensions for Visual Studio and parts of the Windows SDK for Vista!

Is Windows PowerShell Installed?

First task - Is Windows PowerShell installed. We use powershell to build, configure and manage the demo and its source code (more on that later). Since Windows PowerShell on Vista is an OOB update we should be able to find it using the win32_QuickFixEngineering WMI Provider.

get-wmiobject win32_QuickFixEngineering

See the irony in the above command. Anyway, if you know the KB number you are looking from you should be able to find it.

What about the execution policy?

Since we are using powershell scripts, we need to make the user aware that the execution policy on the machine needs to be setup.

get-itemproperty -path HKLM:\SOFTWARE\microsoft\powershell\1\shellids\Microsoft.PowerShell

Should give us the ExecutionPolicy.

Software

Off to a good start, but wait. What software is installed on your machine can be found out many different ways:

  • Registry - If an App uses the registry, you could check there. Windows also uses the registry to store application installation information. Where depends upon how it was installed. Typically we found most people check HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  • File System - we could check for the physical presence of a binary file on the computer. The question is then where do we look. What if the user did not install to the default folder?
  • WMI - There are several WMI classes for inspecting the software on your machine; win32_Product and win32_softwareFeature being 2 examples.

In the end we wrote code to allow us to check using either of those techniques - but we managed to do most software checks using the Uninstall registry location. I suggest you explore the Registry and WMI options.

Sometimes the info in that registry key is a little cryptic. I love Guids for all they give us, but they are not meant for human consumption.

One neat trick using PowerShell was the ability to take a snapshot of the registry key:

$current = dir

Install the software we wanted to test for. Run this:

$newstuff = dir

then see which keys changed using this:

Compare-Object $current $newstuff | format-list

Which output this:

InputObject : HKEY_LOCAL_MACHINE\SOFTWARE\...\Uninstall\{D6D42959-143F-456A-9941-A400FD7B25D8}
SideIndicator : =>

Which tells us the exact keys that were changed!

OS Version

By now we almost look like we know what we are doing. OS Version is WMI Query on win32_OperatingSystem.

Is MSMQ there?

MSMQ is a service - so another WMI query: select * from win32_Service where Name='msmq' should give the correct result.

What about IIS7?

IIS7 is a funny one. In LHS we can use the Win32_ServerComponent WMI provider (which is new to Longhorn Server) to figure out not only what features are installed but also what roles are installed on the server (sounds like the topic of another blog) In Vista its not as clear.

Give me the code right NOW

The Dependency Checker will be shipped as part of the dinnernow source code from https://www.dinnernow.net/ once we hit our magic release date. (shhhhhhh)

THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS