Jump to content

Recommended Posts

Posted (edited)

Hi,

For a management tool I need to query several different values from WMI. Point is, I have to do that from Linux. Yes, I know, this is AutoIT, and it's for Windows. But you guys have proven to be a most often very helpful and professional community, so I thought, let's just ask...you.

On Windows, if I query WMI from VB or AutoIt, I usually do something like this:

Local $wbemFlagReturnImmediately= 0x10
Local $wbemFlagForwardOnly      = 0x20
Local $h_wbemFlags              = $wbemFlagReturnImmediately + $wbemFlagForwardOnly
$s_ComputerName                 = "localhost"
$o_WMIService                   = ObjGet("winmgmts:\\" & $s_ComputerName & "\root\CIMV2")
$o_LogicalDiskC                 = $o_WMIService.ExecQuery("SELECT Size FROM Win32_LogicalDisk WHERE Description = 'Local Fixed Disk' AND Name = 'C:'", "WQL", $h_wbemFlags)

If IsObj ($o_LogicalDiskC) Then
    For $o_item in $o_LogicalDiskC
        ConsoleWrite(@CRLF & $o_item.Size & " Bytes - " & Round($o_item.Size /1024 /1024 /1024, 2) & " GBytes" & @CRLF)
    Next
Else
    ConsoleWrite(@CRLF & "No Object" & @CRLF)
EndIf
Okay. But now I only need the value of .Size and not the collection of (in this case one) object(s) that is returned by the query. So my question: Is there a way to phrase a WMI query in WQL that only returns this value as an int or string or something?

Regards,

Chris

Edited by cherdeg

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...