How MSI tell whether a product installed or not
Posted 06 February 2006 - 16:13
I came across a question that I could not seem to get a definitive answer for. Hope one of you can shed a light on it.
I was trying to retrieve an MSI property of a product in a script. The MSIGetProductInfoProperty() call always returns blank on "INSTALLPROPERTY_INSTALLDATE" (it is supposed to return a date string).
My question is: how does MSI tell if a product is installed or not?
Some document suggests that it check ProductCode, UpgradeCode and ProductVersion. So, it searches the registry, local drive, or both? What is the sequence of events performed by MSI in determining the existence of a product?
Thanks you all in advance!
Posted 06 February 2006 - 18:36
Posted 06 February 2006 - 20:55
You are right on point, I think. This is something I suspected too. Could the information in here:
Note that "SomeID" (with an *) is not the ProductCode - it seems to come from nowhere and varies from installation to installation. Anyway, I was able to track it down since it associates with my product. As a matter of fact, I only only find the ProductCode (the plain GUID) in places like "UninstallString" value, but never as a key.
Back to your obversation. If the ProductCode is compressed, is the compression documented? Or how to decompressed it?
Just a little background about what I wanted to do. I need to do an update on a product which has a different ProductCode than my update and Maor update is not the solution (the marketing does not like the idea of Uninstall/install of major upgrade). So, I may have to tweak the registry before hand so that my upgrade installer thinks I am actually doing a minor upgrade - basically, to modify the registry to trick MSI.
Posted 07 February 2006 - 06:05
If ProductCode is:
The manipulated ProductCode (compression) will always be:
First three parts are inverted and concatenated.
For last two parts the inversion is done in sets of 2 digits, and then concatenated.
I don't know if i am 100% right; but this is what i have observed with a lot of products.
Posted 08 February 2006 - 21:08
However, after changing the ProductCode, the UpgradeCode to match the ones that are in my "Upgrade" table, my upgrade installer simply displays a "Removing" message and disappears immediately. I even could not get the debugger to stop anywahere in my InstallScript.
Could anyone explain how the upgrade installer works?
Posted 09 February 2006 - 02:56
By changing the registry items (ProductCode, UpgradeCode...) to match the ones that are defined in my previous installtion on the target machine, the upgrade installer now is able to recognize the product as somehow "installed". However, when query the "Installed" property of the installed product, I still got nothing (means Not Installed). A subsequent query to the "ProductState" property returns "2" - means it is installed for a different user! I knew my product was installed for "All users" by an administrator! So, why the hack MSI thinks it is installed for someone else? A registry or somewhere is secretly checked by MSI - I guess - which I did not change.
The question now becomes: What MSI will check before it sets the "Installed" property?
Thanks a lot.
Edited by longmian, 09 February 2006 - 03:41.