Jump to content

Recommended Posts

Posted

Hey everyone -

I came up with a crazy idea of combining all the functions I use the most into one UDF that I can personally use and one of them is WMI calls...I was wondering if there was a way to turn it into a function like so:

Func _WMICall ($sQuery, $sQryRtn, $sComputer=".")
    $objWMIService = ObjGet("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & $sComputer & "\root\cimv2")
    If IsObj ($objWMIService) Then
        $colItems = $objWMIService.ExecQuery("SELECT * FROM " & $sQuery , "WQL", 0x10 + 0x20)
        If IsObj($colItems) Then
            For $objItem In $colItems
                ConsoleWrite($objItem. & $sQryRtn & @CRLF) ;also tried $objItem.$sQryRtn
                ;Create and Return Array
            Next
        EndIf
    EndIf
EndFunc

I'm guessing most of you are going to look at that and wonder what I'm on this morning, but I'm just curious if something like this could ever work...Thank for any help in advance.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Posted

You could try with Execute() I guess.

Nope, didn't work. Thanks for the try though.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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
×
×
  • Create New...