MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
September
Sun Mon Tue Wed Thu Fri Sat
           
22
           
2007
Months
Sep


Sat, Sep 22, 2007 11:59 am

Visual Basic Script to Check CPU Utilization

A user of a Windows 2000 Professional system was complaining that his system has been running very slow. He has stated that when he is typing in a Word document or an email message that the time between when he types characters and when they appear on his screen can be quite lengthy. I've seen problems on his system before with high CPU utilization and wanted to use a script that would monitor and record CPU utilization on his system.

I found a script posted on TechRepublic at CPU Utilization Script1. I modified the script so that I could specify the time interval between CPU utilization checks through an argument to the script when it is run. The modified script is available at CPU_Use.vbs 2.

The script can be run with csript /nologo CPU_Use.vbs or alternatively cscript /nologo CPU_Use num where "num" is the number of seconds to wait between CPU checks, e.g. csript /nologo CPU_Use 300 to check every 5 minutes.

The output is placed in C:\Processor.log; the output location can be changed by modifying the value of the strLogFile variable in the script. Output will look similar to the following:

9/22/2007       09:43
9/22/2007       09:48   19
9/22/2007       09:53   17
9/22/2007       09:58   17
9/22/2007       10:03   35
9/22/2007       10:08   14
9/22/2007       10:13   15

The first two columns list the date and time the script was run while the third lists the CPU utilization at the time the script was executed. There is no value for CPU utilization for the first entry in the log.

The script requires Windows XP or later. It will not run on Windows 2000. If it is run on Windows 2000, you will see CPU_Use.vbs(48, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'WbemScripting.Swbemrefresher' 3, 4

Most of the systems I support are Windows XP systems, so the script will still be useful to me, but I can't check the system I wanted to check in this case, since that system is a Windows 2000 system.

References:

  1. CPU Utilization Script
    By: neilb
    Posted: January 4, 2006
    TechRepublic
  2. CPU_Use.vbs
    By: Jim Cameron (modifications to script written by neilb)
    MoonPoint Support
  3. ActiveX component can't create object: 'WbemScripting.Swbemrefresh
    Posted By: Daniel
    Date: April 19, 2005
    Ureader.com - Microsoft community
  4. SWbemRefresher Object
    Microsoft Developer Network

[/languages/vbs] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo