Hi, there is a bug in comtypes.client.GetBestInterface, as this:
---- ## the following code works fine from comtypes.client import CreateObject wscriptObj = CreateObject("Wscript.Shell",dynamic=True) print(wscriptObj.CurrentDirectory) wscriptObj.run("cmd.exe /c notepad.exe",0) # But, when drop the "dynamic=True", it will fail from comtypes.client import CreateObject wscriptObj = CreateObject("Wscript.Shell") print(wscriptObj.CurrentDirectory) # Failed, AttributeError: CurrentDirectory wscriptObj.run("cmd.exe /c notepad.exe",0) ---- Turns out that when progid="Wscript.Shell", in comtypes.client.GetBestInterface, the pci.GetClassInfo() returned TypeInfo of the default interface IWshShell3, not of the supposed CoClass WshShell. GetBestInterface searched IWshShell3, find what it implemented - IWshShell2, which has no property CurrentDirectory. So I think here need an if stmt, such as "if (str(ta.guid) == punk.clsid): go best interface", or, try IDispatch.GetTypeInfo first. LiuPing ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users