473,237 Members | 1,405 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,237 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 5173
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.