Hi all,
Could someone shed some lights upon querying through wmi and win32.client objects?
Anytime i try to query throught win32.client object i get this error:
Error: '' object has no attribute 'UserName'
though, i know (wmic class "Win32_ComputerSystem", wmiexplorer etc.) the certain attribute belongs to the object i'm trying to query on:
import win32com.client
...
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root/cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_ComputerSystem")
for objItem in colItems:{
print objItem.UserName #Error: '' object has no attribute 'UserName'
}
...
And when i run query on wmi object - everything is just fine:
import wmi
...
c = wmi.WMI()
for objItem in c.query(colItems):{
print objItem.UserName # this works now
}
...
What is causing this "no attribute" error? Could this be my OS issue? Running winXP pro, version 2002, sp2. Or is this because of python 2.4 version i am working on?