Jump to content

Recommended Posts

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');
    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]
            ReDim $FuncArray[Number($FuncArray[0][0] + 2)][$ColumnNo]
         _ArrayDisplay($FuncArray, $ClassName,"",0,"|","AccountType|Caption|FullName|Domain|PasswordChangeable|PasswordExpires|PasswordRequired|Description")
        Return 0

Of course in the above code the problem is :


Is there a way to implement this?

Thanks in advance.

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...