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...
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...