To Install/Uninstall/Update our software, our custom installer uses WindowsInstaller.Installer.Products
to get the list of installed products from windows registry.
And on some client machines, an unknown software is probably adding a new entry to the registry 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products' a key with name something like 'ABCD'. This is causing WindowsInstaller.Installer.Products
to throw an exception. I can re create this scenario by manually adding a registry key entry into 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products' named 'test'. And if I rename test to a new GUID then the simulated problem gets solved.
Can you suggest any possible workaround/solution?
Using MSIINV.exe tool would be difficult, as that is a 3rd party tool, but that seems to help.
I'd take a look at the Microsoft.Deployment.WindowsInstaller namespace found in Windows Installer XML (WiX) Deployment Tools Foundation (DTF). It has:
public static IEnumerable<ProductInstallation> GetProducts(
string productCode,
string userSid,
UserContexts context
)
productCode (String)
ProductCode (GUID) of the product instances to be
enumerated. Only instances of products within the scope of the context
specified by the userSid and context parameters will be enumerated.
This parameter may be set to null to enumerate all products in the
specified context.
userSid (String)
Specifies a security identifier
(SID) that restricts the context of enumeration. A SID value other
than s-1-1-0 is considered a user SID and restricts enumeration to the
current user or any user in the system. The special SID string s-1-1-0
(Everyone) specifies enumeration across all users in the system. This
parameter can be set to null to restrict the enumeration scope to the
current user. When context is set to the machine context only, userSid
must be null.
context (UserContexts)
Specifies the user context.
that wraps the Win32 MSI API MsiEnumProductsEx function. This brings back a collection of ProductInstallation that you can do Linq queries against to find out anything you need to know about installed MSI's.