Upgrade Codes, Product Codes, and Silent AIR Application Uninstall

Those who sign up for the Adobe AIR redistribution license have had the ability to silently install and uninstall AIR applications since the AIR 1.0 release. Unfortunately, the silent uninstall support on Windows is a bit rough. I’ve included below a link to a utility I wrote that eases the problem a bit. But first, a little background on the issue.

When an AIR application is installed on Windows, it’s installed via Windows Installer. This is a good thing; it allows leveraging all the capabilities of Windows Installer. For example, silently uninstalling an AIR application on Windows can be accomplished directly via the “msiexec” utility that is part of Windows. All you need to provide to msiexec is the product code of the application.

AIR applications don’t inherently contain product codes—they’re specific to Windows Installer—and you won’t, for example, find one in your application descriptor. Furthermore, Windows Installer requires that product codes change—even for the same application—under certain circumstances. In order to play it safe, AIR generates a unique product code for each version of your application. This, in turn, means you need to know the product code associated with the specific installed version of the application in order to uninstall it. This is a hassle.

Fortunately, Windows Installer also associates an upgrade code with each application. An upgrade code is basically an application identifier that never changes and, given an upgrade code, you can look up the corresponding product code. The mapping from upgrade code to product code is stored in the registry at application install time. Like product codes, AIR generates an upgrade code for your application. Unlike product codes, upgrade codes are the same across all versions of your application and are easily determined via the OSID application that comes with the redistribution support.

Unfortunately, the only way to look up that mapping is via the MsiEnumRelatedProducts() system call, and the msiexec utility won’t do it for you. (Theoretically you can look this mapping up yourself in the registry, but that turns out to be fairly complicated, and I’m not sure it can be done reliably.)

How much of a problem this is depends on the uninstall technology you’re using, whether or not it can perform this lookup for you, and whether or not you’re in a position to write a few lines of C code to perform the lookup. For anyone out of luck on all counts—or just curious—I’ve written a small utility called “msiu2p”. You can download msiu2p here. (The zip package includes the executable and the source.)

Here’s an example:

c:\ msiu2p {8DA920D5-C41C-42E0-BF31-87BA49984EE4}
{A2BCA9F1-566C-4805-97D1-7FDC93386723}
c:\

Of course this isn’t useful just for AIR applications, either: It’s a handy complement to msiexec for any application using Windows Installer.

We plan to improve AIR’s intrinsic support for this kind of thing in an upcoming release. In the meantime, I hope this utility will help fill the gap for those who need it.

8 Responses to Upgrade Codes, Product Codes, and Silent AIR Application Uninstall

  1. Dave Graham says:

    Excellent work Oliver! That will certainly fill the gap – thanks heaps 🙂

  2. will says:

    It would be nice to know where the OSID generator application is located?[Anyone signing up for a redistribution license is given a download link. It’s not otherwise available. —Oliver]

  3. Rob Calhoun says:

    Thanks! This is a helpful little utility!One question: the compiled application has a dependency on msvcr90.dll, right?Thanks,Rob[Probably, yes—default setting in Visual Studio, I believe. —Oliver]

  4. Diego says:

    Great post!!! i have one question, is there any way to generate a .msi package form a .air file?[No, there is not. That is a feature we’re considering for a future release. Starting with AIR 2, it will be possible to create an .exe-based installer from an .air file. —Oliver]

  5. Robert Burke says:

    To remove the dependency on msvcr90.dll, you can change compiler options (http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx). The exe file size goes from 8 KB to 53 KB.

  6. johannes says:

    Is the method described in this post still uptodate? Your write “We plan to improve AIR’s intrinsic support for this kind of thing in an upcoming release.” Did this happen in the meantime? Thanks, Johannes

    • Oliver Goldman says:

      Yes, this post is up to date but no, we have not yet implemented the planned improvements. As always, I encourage you to help us prioritize those (and other) features at ideas.adobe.com/air.

  7. David Scott says:

    For silently installing and uninstalling AIR applications, it seems the new and better way is to use the “AIR Redistribution Helper” (ARH) utility that you can download at the bottom of “http://www.adobe.com/products/air/runtime_distribution3.html” for both Mac and Windows. Instructions for using it are at “http://help.adobe.com/en_US/air/redist/WS485a42d56cd19641-70d979a8124ef20a34b-8000.html”. There is still no ability to silently upgrade an AIR application, but it is easy to locate an existing installation and uninstall it as long as you know the application’s unique identifier (which is in the AIR application descriptor file).