SWbemObjectEx not found

kyosohma at gmail.com kyosohma at gmail.com
Tue Dec 25 14:35:49 EST 2007


On Dec 24, 1:01 pm, jmgmail <jin... at gmail.com> wrote:
> I have a working VBScript and failed to convert it to Python. Can
> someone help?
>
> ==VBScript:==
> Set locator = CreateObject("WbemScripting.SWbemLocator")
> Set Services = locator.ConnectServer("smsroot1","root/SMS/site_A")
> Set instCollection =
> Services.Get("SMS_Collection.CollectionID='A000D9'")
>
> 'Create the direct rule.
> Set instDirectRule =
> Services.Get("SMS_CollectionRuleDirect").SpawnInstance_
> instDirectRule.ResourceClassName = "SMS_R_System"
> instDirectRule.ResourceID = 8566
> instDirectRule.RuleName = "MyDirectRule"
>
> 'Add the direct rule to the collection.
> instCollection.AddMembershipRule instDirectRule
> ==END==
>
> ==Python==
> import sys,os,getopt
> import win32com.client
>
> locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
> locator.Security_.impersonationlevel = 3
> Services = locator.ConnectServer("smsroot1","root/SMS/site_A")
> instCollection = Services.Get("SMS_Collection.CollectionID='A000D9'")
>
> instDirectRule =
> Services.Get("SMS_CollectionRuleDirect").SpawnInstance_()
> instDirectRule.ResourceClassName = "SMS_R_System"
> instDirectRule.ResourceID = 8566
> instDirectRule.RuleName = "MyDirectRule"
>
> instCollection.AddMembershipRule(instDirectRule)
> ==END==
>
> The error from Python is:
> Traceback (most recent call last):
>   File "C:\temp\pushpkg.py", line 19, in ?
>     instCollection.AddMembershipRule(instDirectRule)
>   File "C:\Python24\lib\site-packages\win32com\client\dynamic.py",
> line 491, in
> __getattr__
>     raise pythoncom.com_error, details
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
> 'SWbemObjectEx',
> 'Not found ', None, 0, -2147217406), None)
> ==END==
>
> Spend a whole day on this already and still have no clue.
>
> Thank you.

I'm not seeing the error either. You should post to the PyWin32
mailing list as they have more experience there:

http://mail.python.org/mailman/listinfo/python-win32

Plus, Mark Hammond occasionally answers questions there too. He wrote
(or co-wrote) the module, FYI.

Mike



More information about the Python-list mailing list