eternaluxe Posted July 10, 2009 Posted July 10, 2009 I'm trying to do this, but can't figure the proper format: $result = $result & $obj.$property Here is the full script: $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $thisComputerName = GetSpecificWMI("Name","Win32_ComputerSystem") MsgBox(4096, "Computer name", $thisComputerName) Func GetSpecificWMI($property, $class) $result = "" $specificObj = $objWMIService.ExecQuery("SELECT " & $property & " FROM " & $class & "", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If isObj($specificObj) then For $obj In $specificObj $result = $result & $obj.$property Next EndIf Return $result EndFunc
nguyenbason Posted July 10, 2009 Posted July 10, 2009 What do you want to do? You are assigning value for $result that taking from WMI query? You want to separate each value or what? $result = $result & $obj.$property & "|" UnderWorldVN- Just play the way you like it
eternaluxe Posted July 10, 2009 Author Posted July 10, 2009 For example, in this instance $property = "Name" Change the line inquestion to $result = $result & $obj.Name and it works, but $result = $result & $obj.$property doesn't.
Crystall Posted July 10, 2009 Posted July 10, 2009 (edited) Hello. I've found an solution for your problem. Check this out: Func GetSpecificWMI($property, $class) $result = "" $specificObj = $objWMIService.ExecQuery("SELECT * FROM " & $class & "", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If isObj($specificObj) then For $obj In $specificObj $result = $result & Execute("$obj." & Eval("property")) Next EndIf Return $result EndFunc EDIT: Enjoy this piece of code from Russia Edited July 10, 2009 by Crystall Hello World!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now