473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SWbemObjectEx not found

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").SpawnInst ance_
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.SWbemLocat or")
locator.Security_.impersonationlevel = 3
Services = locator.ConnectServer("smsroot1","root/SMS/site_A")
instCollection = Services.Get("SMS_Collection.CollectionID='A000D9' ")

instDirectRule =
Services.Get("SMS_CollectionRuleDirect").SpawnInst ance_()
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.
Dec 24 '07 #1
2 5199
On Dec 24, 1:01 pm, jmgmail <jin...@gmail.comwrote:
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").SpawnInst ance_
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.SWbemLocat or")
locator.Security_.impersonationlevel = 3
Services = locator.ConnectServer("smsroot1","root/SMS/site_A")
instCollection = Services.Get("SMS_Collection.CollectionID='A000D9' ")

instDirectRule =
Services.Get("SMS_CollectionRuleDirect").SpawnInst ance_()
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
Dec 25 '07 #2
jmgmail 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").SpawnInst ance_
instDirectRule.ResourceClassName = "SMS_R_System"
instDirectRule.ResourceID = 8566
instDirectRule.RuleName = "MyDirectRule"

'Add the direct rule to the collection.
instCollection.AddMembershipRule instDirectRule
==END==
Couple of points here. First off, this is standard WMI stuff
in spite of the slightly awkward way the VBS appears, so if
I may recommend my own WMI module [1] you may find that
easier. Secondly, this will be difficult for anyone to debug
in any depth without having access to the WMI-provided SMS
namespace. But I'll do my best!
==Python==
import sys,os,getopt
import win32com.client

locator = win32com.client.Dispatch("WbemScripting.SWbemLocat or")
locator.Security_.impersonationlevel = 3
Services = locator.ConnectServer("smsroot1","root/SMS/site_A")
instCollection = Services.Get("SMS_Collection.CollectionID='A000D9' ")

instDirectRule =
Services.Get("SMS_CollectionRuleDirect").SpawnInst ance_()
instDirectRule.ResourceClassName = "SMS_R_System"
instDirectRule.ResourceID = 8566
instDirectRule.RuleName = "MyDirectRule"

instCollection.AddMembershipRule(instDirectRule)
==END==
Almost certainly your problem here is that VBS is doing
some slightly fancy stuff behind the scenes to set up
this method call, which you'll have to do for yourself in
Python. Try replacing that last line with (untested, obviously):

<code-snippet>
AddMembershipRule = instCollection.Methods_ ("AddMembershipRule")
InParameters = AddMembershipRule.InParameters
#
# might be 1-indexed; not sure
#
InParameters[0] = instDirectRule
instCollection.ExecMethod_ ("AddMembershipRule", InParameters)

</code-snippet>

Come back if that doesn't help or if it isn't clear what's going
on.

TJG

[1] http://timgolden.me.uk/python/wmi.html
Dec 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rutger Claes | last post by:
Code and problem are from PHP5: When I execute the following piece of code, the DomException is thrown with a message: Not Found Exception. I assume this means that the node I extracted from the...
4
by: amywolfie | last post by:
I would like to put code behind a Find button on a form which: 1) Performs a find based on a field on the form 2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box. ...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
2
by: ypul | last post by:
on my local server i am getting ".net error" of "page not found " but on my hosting server I am not getting .net error ...I am getting the normal page not found error what could be the reason ?...
14
by: NormD | last post by:
We have a client-server app using Web Services on an IIS machine. The trace below shows that .NET is searching around for some things (e.g., SystemDrawing.DLL and System.Drawing.EXE) and taking a...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
5
by: Amit_Basnak | last post by:
Dear Friends I have been getting the following error Error 185: "WorkFlow_dce.cpp", line 58 # Left side of '->' requires a pointer to class; type found was 'struct WF_SEARCH_WU'....
1
Dököll
by: Dököll | last post by:
Greetings, Good buddies! I am for the first time, since I started learning VB, going to build an application I wanted to build for my first son, a language and activities program that will allow...
1
by: sora | last post by:
Hi, I've developed a MFC program under VS 6.0. My debugger *was* working fine and I've used it often for my project. Then, one day, the errors below appear and they prevent me from using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.