CPU performance from command line

  • Thread starter Thread starter FPI
  • Start date Start date
F

FPI

Hi I'm developing a simple Java application. I want to check the CPU
usage/perform in a windows enviroment and store it. How can I get
actual CPU usage. I would prefer something from the command line, but
anything would be great.
Thanks in advance.
 
Process Explorer
http://www.sysinternals.com/Utilities/ProcessExplorer.html

--
Carey Frisch
Microsoft MVP
Windows - Shell/User
Microsoft Community Newsgroups
news://msnews.microsoft.com/

-------------------------------------------------------------------------------------------

:

| Hi I'm developing a simple Java application. I want to check the CPU
| usage/perform in a windows enviroment and store it. How can I get
| actual CPU usage. I would prefer something from the command line, but
| anything would be great.
| Thanks in advance.
 
This .vbs script returns CPU usage, and could be adapted accordingly

'**************************************************************************
set fs = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

Set WMI = GetObject("WinMgmts://")


Set wmiWin32Services = WMI.InstancesOf("WIN32_PROCESSOR")
For each wmiWin32Service in wmiWin32Services
list = ucase(wmiWin32Service.LoadPercentage) & "%"
Next

WshShell.popup list,3,"CPU Usage"
'**************************************************************************


Jon
 
Thanks!
Now only I have a minor project. Read this result from Java. Since I
don't know nothing about VBScript, I cannot modify it.
How can I have this message printed from command line?

Thanks again.
 
This script would output the cpu usage 20 times to the command line

To run from the command line

cscript //nologo filenameyouchose.vbs

or to direct the results to a file
cscript //nologo filenameyouchose.vbs >>results.txt

[Change "counter=20" to "counter=1" if you only want to output the result
once]


Jon


'*********************************************************************
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WMI = GetObject("WinMgmts://")

'Number of times to output cpu usage
counter = 20

do

Set wmiWin32Services = WMI.InstancesOf("WIN32_PROCESSOR")
For each wmiWin32Service in wmiWin32Services
cpuusage = wmiWin32Service.LoadPercentage
Next

'Output the result to the command line or file
WScript.echo cpuusage


counter = counter -1
loop until counter = 0
*************************************************************************************
 
Back
Top