Jump to content

wmi queries


covaks
 Share

Recommended Posts

just a quick question. Is there a way to do this? Or do I have to explicitly name each method/property. eg:

Func RunWmiQuery($Win32_Class, $Property)
    
    Local $file = FileOpen($ServerList, 0)
    Local $file2 = FileOpen($OutputFile, 2)
    Local $Count, $Items
    Local $NumComps = _FileCountLines($ServerList)
    
        While 1
            Local $Computer = FileReadLine($file)
            If @error = -1 Then ExitLoop
            $Count += 1
            _GUICtrlStatusBar_SetText($hStatus, Int(($Count / $NumComps) * 100) & "% Completed - " & $Computer)
            Local $Object = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2")
            If IsObj($Object) Then
                Local $Collection = $Object.ExecQuery("Select * from " & $Win32_Class)
                For $Items In $Collection
                    If GUICtrlRead($Check1) = $GUI_CHECKED Then
                        FileWriteLine($file2, $Computer & "," & $Items.$Property)
                    Else
                        FileWriteLine($file2, $Computer & ": " & $Items.$Property)
                    EndIf
                Next
            Else
                FileWriteLine($file2, "Error connecting to WMI on " & $Computer)
            EndIf
        WEnd
    
    FileClose($file)
    FileClose($file2)

EndFunc

I get an error when compiling in scite. It doesn't like the $Items.$Property thing. It tells me it's a syntax error and points to the $ in front of Property. If I do $Items.SerialNumber for example though, it works fine. The idea is I want to be able to pass things in like this:

RunWmiQuery("Win32_BIOS","SerialNumber")

RunWmiQuery("Win32_Csproduct","IdentifyingNumber")

etc.

Link to comment
Share on other sites

nm. I think you meant CompInfo.au3. I found it. Not really what I was looking for though. It appears I'll have to explicitly name the method/property, as autoit just doesn't like the $var.$var syntax.

Thanks. :-)

Edited by covaks
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...