Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WindowsInstaller.Installer.Products

Status
Not open for further replies.

mrmovie

Technical User
Oct 2, 2002
3,094
GB
Came across an issue with some old code that i have to support. It is making use of :

Set objInstaller = CreateObject("WindowsInstaller.Installer)
For Each aProduct In objInstaller.Products
'blaa
Next

The issue was that a runtime was generated by the For Each line, as objInstaller.Products was returning Null

This was caused by someone / or some product install / upgrade creating a duff entry in:
HKLM\SOFTWARE\Classes\Installer\Products
The duff key wasnt the standard length of the rest of the GUIDs, the WindowsInstaller.Installer COM doesnt like it.

Even if the code had been written to handle this error the .Products collection would still be empty and the rest of the script would have carried on thinking the machine had no products installed.

I was going to write a quick script to:
+ back up the registry
+ loop through the subkeys in Products
+ try .Products, if it errors remove the current subkey
+ try .Products, if it still errors then this current subkey which was removed is fine and can be put back
etc etc

in the end i could see the issue just due to the name of the subkey.

So, i will wouldnt recommend the use of this COM object. I wouldnt recommend the use of iterating through Win32_Product class due to the documented issues with that...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top