Daniel Cazzulino's Blog : Properly detecting application installation on launch conditions

Properly detecting application installation on launch conditions

If you need to detect whether a given application is installed (i.e. you're writing a plugin, or depend on an existing framework/toolkit to be installed), you have a couple options:

  1. Search for a registry key
  2. Search for a Windows Installer component

The first is the easiest, but it's not without problems. For example, I was creating a Windows Live Writer (WLW) plugin and followed the instructions on MSDN on how to deploy it. Most plugins in the Live Gallery use the registry search for the WLW installation folder to determine if the app is installed. This doesn't work on Vista x64, where the registry key is under:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Live\Writer\

instead of:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Live\Writer\

Supposedly this is taken care for you by the OS, but I couldn't make it work with VS setup projects.

The only reliable way to detect if the app has been installed in this scenario is to use method 2) from above: an installer component search. In order to determine the component ID you should be searching for, you can simply open the app installer (not yours, the one you depend on) with the Orca tool and pick a non-optional component from the app:

Orca

Here I just picked the WLW executable component.

Now you just use the ComponentId on the properties window for the launch condition if you're using VS setup projects (which you shouldn't unless it's the most trivial setup in the world and you don't care about having a continuous integration process building it through MSBuild ;), which is typically the case in simple plugins like mine)

posted on Thursday, November 01, 2007 9:19 AM by kzu