Search the Community
Showing results for tags 'Objects obj'.
Found 1 result
Hello Community! I'm working on a script which uses WMI to expose BIOS info. The script works, but it does not release the memory it used to execute the object creation and query. The script will continually wire more and more memory everytime the case is called. As a work around, I've stored the result of the query in a variable in case it's called again, but I would like to figure out how to manage the memory better. The code itself is for HP Bios, so it's not likely to work on a non HP machine. #include <Constants.au3> Opt("TrayMenuMode", 1) TraySetState() $ItemSerial = TrayCreateItem("Serial Number") While 1 $msg = TrayGetMsg() Select Case $msg = $ItemSerial TrayItemSetState($ItemSerial, $TRAY_UNCHECKED) If $Serial = "" Then $objWMI = ObjGet("winmgmts:" & @ComputerName & "rootHPInstrumentedBIOS") If $objWMI = ("") Then BasicSet() $colItems = $objWMI.ExecQuery("SELECT * FROM HPBIOS_BIOSString", "WQL", "wbemFlagReturnImmediately" + "wbemFlagForwardOnly") If IsObj($colItems) Then For $objItems In $colItems If $objItems.Name = "Serial Number" Then $Serial = $objItems.Value EndIf Next EndIf EndIf MsgBox(0, "Serial Number", "Serial Number is " & $Serial, 30) $objWMI = 0 ; This deletes the object For simplicity I pulled out one example from the script, my apologies if something is missing.