Remend Posted September 15, 2016 Posted September 15, 2016 Hello, I started using WMI the other day and due to the ammount of classes I need to call in different cases, I thought it would be nice to create a general function. Func GetObjects($ClassName,$ColumnNo,$FieldsAr) Local $FuncArray[2][$ColumnNo] $FuncArray[0][0] = 0 If Not IsDeclared("Obj_WMIService") Then Global $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2'); EndIf If (IsObj($Obj_WMIService)) And (Not @error) Then Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from ' & $ClassName) Local $Obj_Items, $i For $Obj_Items In $Col_Items $FuncArray[0][0] += 1 For $i = 0 to $ColumnNo-1 $FuncArray[Number($FuncArray[0][0])][$i] = $Obj_Items.$FieldsAr[$i] Next ReDim $FuncArray[Number($FuncArray[0][0] + 2)][$ColumnNo] Next _ArrayDisplay($FuncArray, $ClassName,"",0,"|","AccountType|Caption|FullName|Domain|PasswordChangeable|PasswordExpires|PasswordRequired|Description") Else Return 0 EndIf EndFunc Of course in the above code the problem is : $Obj_Items.$FieldsAr[$i] Is there a way to implement this? Thanks in advance.
genius257 Posted September 15, 2016 Posted September 15, 2016 Execute("$Obj_Items."&$FieldsAr[$i]) To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
Remend Posted September 15, 2016 Author Posted September 15, 2016 57 minutes ago, genius257 said: Execute("$Obj_Items."&$FieldsAr[$i]) Thank you very much, it worked.
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