Checking for .NET 1.1 Service Pack 1 in an MSI#

If you're using a Setup Project to build an MSI installer for your project inside Visual Studio .NET, there are quite some options that allow you to control the installation process. One of the properties you can configure are launch conditions, which allow your installer to check some registry values, installed programs or files to determine if the application can be installed at all.

Now there are a number of cumbersome methods to determine whether service packs are installed on the .NET Framework, but fortunately service pack discovery has been made much easier in .NET 1.1.

If your application requires .NET 1.1 with Service Pack 1 to be installed, you can check the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322 registry key for the SP value (which is a DWORD). If its value doesn't exist, you don't have .NET 1.1 installed; otherwise, it contains the installed Service Pack (or 0 if you don't have any service packs).

Now you can add a Search for the service pack in the installer and store it in a property named "SERVICEPACK":

In the actual launch condition, you can check that property to make sure the service pack has been installed, and point them to the official .NET 1.1 SP1 download page if that's not the case:

The tricky part is the Condition, which is set to NOT(SERVICEPACK="") AND NOT(SERVICEPACK>>"0"). Since MSI prefixes DWORD registry values with a # sign in front of them, the SERVICEPACK property will actually contain a "#0" or "#1" string, not the actual service pack number. So we first check if the property actually exists to check for .NET 1.1 (an empty string would be returned if the key didn't exist in the registry) and then we use the special substring operator >> to make sure the property doesn't end with "0". This way, it will work even for service packs later than SP1 (until SP10 arrives of course, but I don't expect that any time soon).

Now if anybody launches the installer without the required service pack, they will get the following screen prompting them to download it:

Blog | Programming | .NET | VS.NET | Samples
Thursday, June 7, 2007 11:41:25 AM (Romance Daylight Time, UTC+02:00)
I would like to thank you for this useful article. It helped me to guide the user of my application to follow installation steps.
Comments are closed.
All content © 2015, Jelle Druyts
On this page
Top Picks
Total Posts: 351
This Year: 0
This Month: 0
This Week: 0
Comments: 530
This is my personal website, not my boss', not my mother's, and certainly not the pope's. My personal opinions may be irrelevant, inaccurate, boring or even plain wrong, I'm sorry if that makes you feel uncomfortable. But then again, you don't have to read them, I just hope you'll find something interesting here now and then. I'll certainly do my best. But if you don't like it, go read the pope's blog. I'm sure it's fascinating.

Powered by:
newtelligence dasBlog 2.3.12105.0

Sign In