Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Component reference counting


7 replies to this topic

AP11

AP11
  • Full Members
  • 3 posts

Posted 27 October 2010 - 14:11

Hi, I was trying my hand at WiX and came across this scenario.
I have product A with a WiX installer. Now in this installer, in a component with id X, I use the
CODE
<RegistryKey/>
tag to write a Key and some values in HKLM hive.
Some days later, i observed that after un-installing the product, the registry entries were not deleted.
This was hard to debug, but i accidentally came across another developer who copied my WiX file for reference, but forgot to change the component Id.
Now, we have two products A and B, with same component ID X as one of the component and only product A writes to registry.
However, i see that the registry entries are deleted only after uninstalling Both the products.
So, what i understand is that there is some reference counting on which component has written to the registry, and the entries are deleted only after the whole component was un-installed. I resolved the problem by setting the component id in product B to a new value.
Now, my question, when I first saw the registry entries not being deleted after uninstalling product A, is there some way (some API, or WMI or anything), using which I can find what all components ( or at least what all products ) are referring to that registry entry which did not get deleted?

Any solution or a way to debug this will greatly help me. Thanks a lot.


VBScab

VBScab
  • Full Members
  • 436 posts

Posted 27 October 2010 - 17:22

The only way I can think of off the top of my head would be a scripted solution, whereby a script loops through each MSI in %SystemRoot%\Installer looking for the relevant key in the Registry table. If found, it would divine the ComponentID (to match it against the machine's record of that component having been installed). If a match is found, the ProductName (and whatever other data you need) can be presented/logged.
- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 27 October 2010 - 18:22

That's the only way I can think of, too. And it can become tricky if properties are involved (i.e. the value name might be determined at install time).

A conflict solver (available as part of some msi products for system administrators) should be able to catch such a problem if you feed it all your msi files.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 27 October 2010 - 18:27

Of course, the correct solution is to create your setup properly with re-using GUIDs smile.gif

Trivia fact: In the early days of msi GUID reuse apparently was a problem. Microsoft created ICE73 especially to make sure no-one re-uses the ProductCode, PackageCode or UpgradeCode GUIDs of Orca or other Windows Installer SDK samples.

AP11

AP11
  • Full Members
  • 3 posts

Posted 27 October 2010 - 19:55

Thanks a lot for the replies. Really appreciate it.

However, I am new to MSI stuff, so i don't really understand how the %SystemRoot%\Installer folder works. What I believe is that the MSI runtime (or Windows perhaps), will store a copy of the MSI which I am trying to install in this folder. This copy will be used when i try to repair/un-install the product. After I un-install, this copy will be deleted. This is my assumption.

Now, taking that my assumption is correct, in my scenario above, product A wrote the registry entries and it is already un-installed. The entries still remain since product B has same component ID as the component in product A which wrote the entries. However, product B does not write to registry. In fact it doesn't have a Registry table.
Now, if I scan through the MSI's in %systemroot%\installer, I wouldn't find any MSI which refers to that registry entry.
Somehow, i think there is this relation between the component id and the registry entry which Window/MSI runtime must be storing somewhere. Is there any way to find it?


VBScab

VBScab
  • Full Members
  • 436 posts

Posted 28 October 2010 - 08:07

My response was meant as guidance rather than any concrete "fix". Maybe you would collect several data sets and come to a conclusion.

For example, if you have an entry 'HKLM\Software\Bloggs Inc', but no reference in any MSI to that entry and no folder '%ProgramFiles%\Bloggs Inc', it's probably safe to delete the entry.
- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 28 October 2010 - 10:18

Windows Installer keeps a reference about which products are clients of which components.
But you'd better scan through all your msi files (before you release them) to detect any duplicate component IDs.

AP11

AP11
  • Full Members
  • 3 posts

Posted 29 October 2010 - 11:27

Thanks all for the guidance.