John Randolph wrote:
Hi list:

I've been beating my head against this problem for 2 days and can't
figure it out.  Searching the archives produced a semi-relevant thread
from the past but the former fixes haven't worked for me.

Using wmi 1.3.2, I've got the following simple code:

    system = wmih.SMS_R_System(NetbiosName=hostname)
    new_rule = wmih.SMS_CollectionRuleDirect.new()
    new_rule.ResourceID = system[0].ResourceID
    new_rule.RuleName = '%s (%d)' % (hostname, system[0].ResourceID)
    new_rule.ResourceClassName = 'SMS_R_System'
    query_id, rv = c.AddMembershipRule(new_rule)

I've also tried getting the method InParameters, populating them and
calling the method directly as previous list traffic experimented
with.

However, neither method allows me to add the rule.   The code above
produces the following exception:

  File "remotewmi.py", line 115, in PolicyInstall
    query_id, rv = c.AddMembershipRule(new_rule)
  File "C:\Documents and Settings\jrand\wmi.py", line 396, in __call__
    handle_com_error (error_info)
  File "C:\Documents and Settings\jrand\wmi.py", line 189, in handle_com_error
    raise x_wmi, "\n".join (exception_string)
wmi.x_wmi: -0x7ffdfff7 - Exception occurred.
  Error in: SWbemObjectEx
  -0x7ffbefff - Generic failure


Don't you love those "Generic failure" messages? I need to
put some better conversion code in there to help you
search for the error code. -0x7ffbefff is 0x80041001
when you twiddle the bits around, and that throws up
this kind of post:

 
http://myitforum.com/cs2/blogs/scassells/archive/2007/02/07/2147217407-error-or-80041001-how-to-avoid-progromatically.aspx

and this:

 
http://www.myitforum.com/forums/m_52995/mpage_1/key_gathering%252Ccollection%252Call%252Cworkstation%252Cdomain/tm.htm#52995

The first suggests a delay might help. The second doesn't come to
any conclusion except that if the last poster got it working then
it's something a bit environmental. Try the delay, perhaps.
FWIW, the WMI code probably isn't calling Put_ on your
newly-created object, because it (probably) doesn't
have a Path_ -- it hasn't come off the WMI database.
According to the example at:

 http://msdn.microsoft.com/en-us/library/ms815919.aspx

that's correct. But just in case it makes a difference
you can try calling new_rule.Put_ () before you add it
to the collection. My feeling is that it will fail but
YMMV.

I'm afraid I'm not at all familiar with SMS and I'm certainly
nowhere near an installation, so it's hard for me to test or
reproduce the issue. Feel free to post back and I'm happy
to diagnose at a distance or to produce debug probes in the
WMI code itself.

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to