def RunWMIQuery(query, baseobj='winmgmts:\\root\\cimv2'):
 pythoncom.CoInitialize()
 wmi_obj = win32com.client.GetObject(baseobj)
 wmi_obj.Security_.Privileges.AddAsString('SeDebugPrivilege')
 try:
  query_results = wmi_obj.ExecQuery(query)
 except pythoncom.com_error as e:
  raise RuntimeError(("Failed to run WMI query '%s' err was %s" % (query, e)))
 try:
  for result in query_results:
   response = rdf_protodict.Dict()
   properties = (list(result.Properties_) + list(getattr(result, 'SystemProperties_', [])))
   for prop in properties:
    if (prop.Name not in IGNORE_PROPS):
     response.SetItem(prop.Name, prop.Value, raise_on_error=False)
   (yield response)
 except pythoncom.com_error as e:
  raise RuntimeError(("WMI query data error on query '%s' err was %s" % (e, query)))

def RunWMIQuery ( query , baseobj = 'winmgmts:\\root\\cimv2' ) : pythoncom . CoInitialize ( ) wmi_obj = win32com . client . GetObject ( baseobj ) wmi_obj . Security_ . Privileges . AddAsString ( 'SeDebugPrivilege' ) try : query_results = wmi_obj . ExecQuery ( query ) except pythoncom . com_error as e : raise RuntimeError ( ( "Failed to run WMI query '%s' err was %s" % ( query , e ) ) ) try : for result in query_results : response = rdf_protodict . Dict ( ) properties = ( list ( result . Properties_ ) + list ( getattr ( result , 'SystemProperties_' , [ ] ) ) ) for prop in properties : if ( prop . Name not in IGNORE_PROPS ) : response . SetItem ( prop . Name , prop . Value , raise_on_error = False ) ( yield response ) except pythoncom . com_error as e : raise RuntimeError ( ( "WMI query data error on query '%s' err was %s" % ( e , query ) ) )
run a wmi query and return a result .