I’m trying to control latest Sun VirtualBox via it’s COM interface from Python. But, unfortunately, the following code don’t work:
import win32com.client
VBOX_GUID = "{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}"
try :
oVbox = win32com.client.Dispatch( VBOX_GUID )
oVbox.FindMachine( "kubuntu" )
except Exception as oEx:
print str( oEx )
Error is general “(-2147467262, ‘No such interface supported’, None, None)”
It seems that the wrong part is my COM handing via Python. Anyone can drop a look and suggest some obvious thing i’m doing wrong?
The problem is that the object returned by
FindMachine("kubuntu")does not support theIDispatch interface, and win32com does not support that.You could use my
comtypespackage http://starship.python.net/crew/theller/comtypes/ for that, but you need to patch the version in the repository to make it work with the VirtualBox type libraries.Here’s a demo session:
And here is the patch that you need: