View Full Version : How do I detect already installed?

12-21-2004, 07:15 PM
Hello. I am using Installshield X Express, and my boss wants our install programs to install whether there is an older version present or not. We don't want to use the upgrade paths feature, because uninstalling should not be required. The changes between versions are very minor.

Essentially, the setup program needs to do this:
1. If product has never been installed, then install.
2. If product has been installed (either same version or earlier, but same product code), then reinstall in case files have been changed or added. I have heard this behavior described as a Minor Update.

The problem is that I can't seem to have one setup program do both of these things. If I add the REINSTALLMODE=v stuff to the setup.ini to get minor updates to work, then the basic new install no longer works. If I take it out, then the basic install works, but minor updates won't work.

How can I get both behaviors? Please help.

12-22-2004, 09:33 AM
p.s. If you're wondering where the title of the post comes from, one of the work arounds I'm thinking of is to write a wrapper application that calls the Setup.exe only after checking whether the product has been installed before. However, I'm not sure how to detect that. Search the registry for the product code GUID? Is there a particular registry section that I should look in? Anyway, I'm hoping for a better answer, but that's my current fallback, so if anyone knows a reliable way to tell if the product is already installed, that would be helpful too.

12-22-2004, 02:28 PM
OK, I think I have the solution to my problem now. I'll put it on here in case anyone else has this same requirement. Before I describe the solution, I'll list a couple of facts that I learned along the way:

1. The Express product really isn't designed to deal with small or minor updates. So anything along those lines requires a work around. It has an Upgrade Path feature for Major upgrades and an Update Service feature, but those really aren't the same thing. If you try to run an Express install on a computer that already has the same product installed, you get one of two cases:
a) If you are running the same exact package, then you get the modify/repair/remove dialog. That seems reasonable.
b) If you are running with the same product code but a different package code you get a Windows Installer dialog telling you that "Another version of the product is already installed". The install then exits. This is the dialog that first made me realize that minor updates weren't directly supported.

2. That said, you can still do a small/minor update program by setting CmdLine=REINSTALLMODE=vomus REINSTALL=ALL in the Setup.ini file, after you have compiled the project. However, you are essentially already outside of the product in the realm of workarounds when you do this. That means you lose the ini change after every compile. Another way in which you really feel this is that you don't appear to get any of your custom actions with a reinstall. You also only get a subset of the dialogs (Welcome, Progress, Finish), but that seems reasonable since most of the important decisions were made during the initial install.

Perhaps the more troubleing problem, though, is that once you make the above change to the setup.ini file, you cannot use the install for "first time" installs. It now only functions for reinstalling existing features. However, there is one tiny glimmer of hope here, and that is that if it doesn't detect a previous version (i.e., it's a "first time" install) then it WILL run your custom actions (at least the Before System Search ones which were all I needed for my work around).

3. To get around this limitation, it is possible to use a custom action from one of the Before System Search hooks to reset the REINSTALL and REINSTALLMODE properties back to their defaults. Obviously you only want to do this for "first time" installs, so you must check the registry for the ABSENCE of the product code (indicating that the product has never been installed before (with this product code)). You can do that by setting up a condition for the custom action.

By resetting the REINSTALL property with the custom action, you can get the first time install to work (and it will still fire your other custom actions).

To summarize, it is possible to go outside of Express and change your normal install into a small/minor update via the setup.ini file. Then, you can use a custom action to change your small/minor update back into a normal install if you detect that the product has never been installed before. The important thing here is that it seems that you cannot do it the opposite way. That is, you cannot leave the setup.ini alone and use a custom action to turn a normal install into a small/minor update. The reason for this is that it detects, on its own, that a previous version is installed and pops up a dialog and exits BEFORE any custom actions fire. You can see this by placing a msgbox in a vbscript custom action in the very first hook. The msgbox will not fire on a reinstall/update.

Anyway, I have added exact steps below for what I did to make my generic test project work:

1. Add a vbscript custom action to "Before System Search (Not in Silent Mode)"

2. Point it to a .vbs file that contains something like this:

Session.Property("REINSTALL") = ""
Session.Property("REINSTALLMODE") = "omus"

3. Add a "Software" condition to the custom action. Choose Registry Entry for the search, then

[Note: I've been told it doesn't work if you leave the Value blank.]

Then choose Not Found from the radio buttons (should see the red x in the checkbox)

4. Compile the project.

5. Modify the Setup.ini, setting CmdLine=REINSTALLMODE=vomus REINSTALL=ALL

That's it. Finished. Should handle both normal installation and small/minor updates.

At any rate, this was the only combination that worked for me. If there is a better way, I'm all ears. I apologize for the long-winded explanation, but I felt I should write all of the things that I wish I had known before I began this mission.