Sign in to follow this  
Followers 0
billthecreator

CPU usage

8 posts in this topic




$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

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

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  
Followers 0