我在Windows XP上并拥有第三方应用程序,我希望能够使用Python脚本打开它。我该怎么做呢?
from win32com.client import Dispatch
mySuite = Dispatch("TestSuite.Application")
抛出错误
File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\Script1.py", line 2, in <module>
mySuite = Dispatch("TestSuite.Application")
File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)
任何指针?感谢。
答案 0 :(得分:1)
看起来TestSuite.Application COM类尚未注册 - 尝试在VBScript中打开它来验证,它也应该失败。在这种情况下,您可以使用regsvr32.exe或类似工具进行修复。