rudi Posted August 9, 2010 Share Posted August 9, 2010 Hi. Playing around with WMI queries, I'm wondering, if it's possible to use variables somehow as shown below, as it would be more "readable" to declare just *ONE* array in the top part of my script. Like this one, whichdoesn't work, as the variable "behind the dot" isn't allowed: expandcollapse popup; Processors ; autoit 3.3.6.1 ; Rudolf Thilo Global $objWMIService, $colItems, $sWMIService, $sName, $sModel $result = "" Dim $CPU_ARR[10][3] = [[9], _ ; 0=what to ask for. 1=result. 2=tagging, not used here. ["AddressWidth"], _ ["DataWidth"], _ ["caption"], _ ["NumberOfCores"], _ ["NumberOfLogicalProcessors"], _ ["CurrentClockSpeed"], _ ["MaxClockSpeed"], _ ["L2CacheSize"], _ ["LoadPercentage"]] $sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2" $objWMIService = ObjGet($sWMIService) If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor") If IsObj($colItems) Then For $oItem In $colItems for $i = 1 to $CPU_ARR[0][0] $CPU_ARR[$i][1]=$oItem.$CPU_ARR[$i][0] ; this should come to $oItem.AddressWidth for $i=1 Next Next Else $result &= "Failed to get Win32_Processor." EndIf Else $result &= "Failed to connect to WMI at: " & $sWMIService EndIf Any suggestions to point out what I miss are appreciated, regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 9, 2010 Share Posted August 9, 2010 (edited) Hmm, I wonder how we might execute something like that...? #include <Array.au3> ; For _ArrayDisplay() only Global $objWMIService, $colItems, $sWMIService Dim $CPU_ARR[10][3] = [[9], _ ; 0=what to ask for. 1=result. 2=tagging, not used here. ["AddressWidth"], _ ["DataWidth"], _ ["caption"], _ ["NumberOfCores"], _ ["NumberOfLogicalProcessors"], _ ["CurrentClockSpeed"], _ ["MaxClockSpeed"], _ ["L2CacheSize"], _ ["LoadPercentage"]] $sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2" $objWMIService = ObjGet($sWMIService) If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor") If IsObj($colItems) Then For $oItem In $colItems for $i = 1 to $CPU_ARR[0][0] $CPU_ARR[$i][1] = Execute("$oItem." & $CPU_ARR[$i][0]) ; this should come to $oItem.AddressWidth for $i=1 Next Next Else ConsoleWrite("Failed to get Win32_Processor." & @LF) EndIf Else ConsoleWrite("Failed to connect to WMI at: " & $sWMIService & @LF) EndIf _ArrayDisplay($CPU_ARR, "$CPU_ARR") Edited August 9, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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