More example code can be found at:
http://www.planetmps.com/
import(win32com.client) import string def(GetValue(N, obj)) pos = 0 pos1 = 0 N = N + " = " Name = Str(N) s = Str(obj.GetObjectText_()) pos = s.find(Name) if pos > 0: pos = pos + len(Name) pos1 = len(s) s = s[pos : pos1] pos = s.find(";") s = s[0 : pos] s = s.replace("{", "") s = s.replace("}", "") s = s.replace('"', "") return (s) else: return ("") def(WMIDateStringToDate(dtmDate)) strDateTime = "" if (dtmDate[4] == 0): strDateTime = dtmDate[5] + '/' else: strDateTime = dtmDate[4] + dtmDate[5] + '/' if (dtmDate[6] == 0): strDateTime = strDateTime + dtmDate[7] + '/' else: strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + '/' strDateTime = strDateTime + dtmDate[0] + dtmDate[1] + dtmDate[2] + dtmDate[3] + " " + dtmDate[8] + dtmDate[9] + ":" + dtmDate[10] + dtmDate[11] +':' + dtmDate[12] + dtmDate[13] return strDateTime strComputer = "." locator = win32com.client.Dispatch("WbemScripting.SWbemLocator") sService = locator.ConnectServer(strComputer, "root/CIMV2/ms_409") ob = service.Get("Win32_BIOS") objset = ob.Instances_ for obj in objset: for prop in obj.Properties_: value = GetValue(prop.Name, obj) if Len(value) > 0: if prop.CIMType == 101: value = WMIDateStringToDate(value) print(prop.Name + " " + value)
No comments:
Post a Comment