1.

Solve : need a script to monitor CPU usage on PC?

Answer»

Hi all,
I need to run a script to load URLs from a plain file into a browser window and monitor CPU usage on PC.
Any idea's welcome.
Thanks.
Not very elegant, but this might work.

CODE: [Select]SET objIE = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const TriStateUseDefault = -2
Const ForReading = 1

strComputer = "."

Set f = fso.GetFile("c:\URL.txt")            '<== Change Path to URL File
Set fs = f.OpenAsTextStream(ForReading, TriStateUseDefault)

While fs.AtEndOfStream <> True
      url = fs.Readline
      objIE.Navigate url

      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
      Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
    wbemFlagReturnImmediately + wbemFlagForwardOnly)

      For Each objItem In colItems
     WScript.Echo url & "  LoadPercentage: " & objItem.LoadPercentage
      Next
      
      While objIE.Busy = True
      Wend

Wend

objIE.Quit
fs.Close

Be sure to change the path to the URL file. URLs in the file should be in the format http://

Save the script with a VBS extension and run from the command prompt: cscript scriptname.vbs
 
Good LUCK.  8-)

Note: You will not see IE as it's never made visible. Also, keep in mind that the script itself will add to the CPU load.Thank you



Discussion

No Comment Found