Sign in to follow this  
Followers 0
dewired

WMI script problem

4 posts in this topic

Im attempting to try some WMI scripting but I cant seem to get started. Ive tried using a half dozen code examples and get the same problem on all of them.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")

set $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

I cant get past this point, I keep getting

set $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

set $colItems = $objWMIService.E^ERROR

Error: UNable to parse line.

Different examples very in the exact query but they all fail with the $objWMIService.E^ERROR.

I have tried using AutoIt 3.1.1 and the beta 3.1.1.91 on WXP.

Anyone know why this doesnt work, am I missing something?

Share this post


Link to post
Share on other sites



Try it without the 'set' command:

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Share this post


Link to post
Share on other sites

Sample code:

; Determine the speed of a processor installed in a computer
; 1 December 2005 by Geert (NL)
; Translated VBScript source code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__computer_hardware.asp
; AutoIt 3.1.x Beta needed

$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_Processor")
For $objItem In $colItems
    MsgBox(0, "", "Processor Id: " & $objItem.ProcessorId)
    MsgBox(0, "", "Maximum Clock Speed: " & $objItem.MaxClockSpeed)
Next

Share this post


Link to post
Share on other sites

I may have figured this out. I tried your code but still I had the same problem. I didnt realize I had to toggle the beta on, once I did that the other examples work.

The set was just something I through in on that one script trying to get it to work.

Thanks

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
Sign in to follow this  
Followers 0