Jump to content

Object function

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.

Share this post

Link to post
Share on other sites
57 minutes ago, genius257 said:


Thank you very much, it worked.

Share this post

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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.