5

I'm trying to call WindowsInstaller.Installer.ProductsEx from python, and can't figure out how to make it work.

Here's a vbscript version of what I want to call from python:

dim msi, products
set msi = CreateObject("WindowsInstaller.Installer")
set products = msi.ProductsEx("", "s-1-1-0", 7)

I think my issue is ProductsEx is a read-only get property that takes 3 arguments, and I don't know how to convince win32com or comtypes to call it that way.

I tried:

>>> import win32com.client
>>> msi = win32com.client.Dispatch('WindowsInstaller.Installer')
>>> products = msi.ProductsEx('', 's-1-1-0', 7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<COMObject WindowsInstaller.Installer>", line 2, in ProductsEx
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

and similiar using comtypes:

>>> import comtypes.client
>>> msi = comtypes.client.CreateObject('WindowsInstaller.Installer')
>>> products = msi.ProductsEx['', 's-1-1-0', 7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\comtypes\client\dynamic.py", line 46, in __getitem__
**dict(_invkind=comtypes.automation.DISPATCH_PROPERTYGET))
  File "C:\Python27\lib\site-packages\comtypes\automation.py", line 768, in Invoke
 args))
_ctypes.COMError: (-2147352571, 'Type mismatch.', ('TypeError: Parameter 1', (('', 's-1-1-0', 7),)))

I think I got closer in comtypes since DISPATCH_PROPERTYGET is what I want to do. In both libs I tried every syntax I could think of:

  • msi.ProductsEx(['', 's-1-1-0', 7])
  • msi.ProductsEx[['', 's-1-1-0', 7]]
  • msi.ProductsEx['']['s-1-1-0'][7]
  • None instead of ''
  • tuples instead of lists

How do I call a COM "get" property with multiple arguments from python?

Ryan Davis
  • 701
  • 8
  • 12

1 Answers1

0

Use Get/Set

msi.GetProductsEx("", "s-1-1-0", 7)