jglouie
jglouie

Reputation: 12880

Ennforcing mutually exclusive install on Windows?

We have Product A and Product A'. They're nearly identical and easily confused. For legal reasons, it is necessary to keep these subtly different. For technical reasons, it is not possible for the two to co-exist and run correctly. Therefore, we want to prevent the user from installing Product A if Product A' is already installed, and vice versa.

Is there a best practice for enforcing this on Windows?

My initial thought is to use a different upgrade code for Product A and A' and use this to clue in that the other is installed, but I'm sure there are other approaches and/or best practices.

Upvotes: 2

Views: 329

Answers (3)

Mark Rovetta
Mark Rovetta

Reputation: 691

I believe the Windows Installer package developer is able do this without resorting to custom actions by Using Properties in Conditional Statements.

The LaunchConditions action queries the LaunchCondition table and evaluates each conditional statement recorded there. If any of these conditional statements fail, an error message is displayed to the user and the installation is terminated.

The LaunchConditions action is normally the first in the sequence, but the AppSearch Action may be sequenced before the LaunchConditions action.

The AppSearch action uses file signatures to search for existing versions of products. The AppSearch action can also be used to set a property to the existing value of an registry or .ini file entry.

The first time the Installer finds the file signature at a suggested location, it stops searching for this file or directory, and sets the corresponding property in the AppSearch Table. That property can then be evaluated using Conditional Statement Syntax in the LaunchCondition table.

Upvotes: 3

BryanJ
BryanJ

Reputation: 8563

You could use a custom action to enumerate through the list of installed products.

//using using Microsoft.Deployment.WindowsInstaller;

IEnumerable<ProductInstallation> installedProducts = ProductInstallation.GetProducts(null, null, Microsoft.Deployment.WindowsInstaller.UserContexts.Machine);
foreach (ProductInstallation installedProduct in installedProducts)
    {
        if (installedProduct.ProductName == "Name of Product A'")
        {
            // set some property in your installer to indicate the product can't be installed
        }
    }

Upvotes: 3

damoiser
damoiser

Reputation: 6238

I haven't do before, but a solution is to storing a key-value on Windows registry when installing (first time) the product A (or A').

Every time, the installer of A (or A') runs, it checks if that key exists, if true abort the installation, else continue with installation. Remember if the user uninstall the product, then remove the key in the registry too.

For more info about Windows registry: http://en.wikipedia.org/wiki/Windows_Registry

For information about add, edit, delete keys: http://support.microsoft.com/kb/310516

Upvotes: 2

Related Questions