Jump to content
Sign in to follow this  
billthecreator

CPU usage

Recommended Posts

billthecreator

what about the part,

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")

what do i have to change to get that working?


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites
NELyon

$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
for $stuff in $objWMIService
    MsgBox(0, "CPU", $stuff.loadpercentage & "%")
next

Severely untested, and i doubt this works, but it's worth a shot.

Share this post


Link to post
Share on other sites
therks

It doesn't need to be changed.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")

$colItems = $objWMIService.ExecQuery("SELECT LoadPercentage FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
    $iCPU = 0
    For $objItem In $colItems
        $iCPU += 1
        MsgBox(0, 'CPU #' & $iCPU, $objItem.LoadPercentage)
    Next
EndIf

There you go.

Share this post


Link to post
Share on other sites
billthecreator

i keep getting this error

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

$colItems = $objWMIService^ ERROR

what should i do?


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

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  

×

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.