Determine CPU usage percentage in windows xp
Moderator: DosItHelp
Determine CPU usage percentage in windows xp
Hi,
Is there any way to Determine CPU usage percentage in windows xp and if CPU running below 40% then do this task?
Thanks
Is there any way to Determine CPU usage percentage in windows xp and if CPU running below 40% then do this task?
Thanks
-
- Posts: 26
- Joined: 03 Dec 2013 12:34
Re: Determine CPU usage percentage in windows xp
look in task manager for usage but as for the batch file im not sure 

Re: Determine CPU usage percentage in windows xp
One way to retrieve the number of processors is using WMIC eg;
A way to retrieve CPU load is typeperf.EXE eg;
total;
or per process;
and divide the load ( typeperf ) by numOfCores;
These are XP native.
Code: Select all
path WIN32_PROCESSOR get NumberOfLogicalProcessors.
Code: Select all
for %%? in ( be, nl ) do if /i "!§lang!" == "%%~?" set "$cmd=Percentage processortijd"
for %%? in ( us, uk ) do if /i "!§lang!" == "%%~?" set "$cmd=Processor Time"
Code: Select all
'typeperf.EXE "\Proces(*)\!$cmd!" -sc 1'
Code: Select all
'typeperf.EXE "\Proces(^!$p^!)\!$cmd!" -sc 1'
Code: Select all
set /a $cpu = $typeperf / $cores
Re: Determine CPU usage percentage in windows xp
Ed Dyreen wrote:One way to retrieve the number of processors is using WMIC eg;A way to retrieve CPU load is typeperf.EXE eg;Code: Select all
path WIN32_PROCESSOR get NumberOfLogicalProcessors.
total;Code: Select all
for %%? in ( be, nl ) do if /i "!§lang!" == "%%~?" set "$cmd=Percentage processortijd"
for %%? in ( us, uk ) do if /i "!§lang!" == "%%~?" set "$cmd=Processor Time"or per process;Code: Select all
'typeperf.EXE "\Proces(*)\!$cmd!" -sc 1'
and divide the load ( typeperf ) by numOfCores;Code: Select all
'typeperf.EXE "\Proces(^!$p^!)\!$cmd!" -sc 1'
These are XP native.Code: Select all
set /a $cpu = $typeperf / $cores
Ed Dyreen,
Thank you for your reply. The code you gave me are not working. I used this code below code and it work and writes CPU usage percentage to csv file. Now i need a way that this code monitor CPU usage for 6 times and if at any of the time CPU usage is below 50% then run command A other wise Run command B. Could you please tell me how to do this...
Code: Select all
typeperf "\processor(_Total)\% Processor Time" -O C:\SS64demo1.csv -SC 6
Awaiting
Re: Determine CPU usage percentage in windows xp
Is there Any body who can solve this,,,,,,,,,
I need a way that this below code monitor CPU usage for 6 times and if at any of the time CPU usage is below 50% then run command A other wise Run command B.
Awaiting
I need a way that this below code monitor CPU usage for 6 times and if at any of the time CPU usage is below 50% then run command A other wise Run command B.
Code: Select all
typeperf "\processor(_Total)\% Processor Time" -O C:\SS64demo1.csv -SC 6
Awaiting
Re: Determine CPU usage percentage in windows xp
See if this floats your boat:
Code: Select all
@echo off
set "cpu="
for /f "skip=1" %%a in ('wmic cpu get loadpercentage') do if not defined cpu set "cpu=%%a"
if %cpu% GTR 50 (
call batchA
) else (
call batchB
)
pause
Re: Determine CPU usage percentage in windows xp
foxidrive wrote:See if this floats your boat:Code: Select all
@echo off
set "cpu="
for /f "skip=1" %%a in ('wmic cpu get loadpercentage') do if not defined cpu set "cpu=%%a"
if %cpu% GTR 50 (
call batchA
) else (
call batchB
)
pause
Foxidrive,,, You are great,,,,,,,,,,,,,,,,,, It worked like a charm,,,,, I thought it is not possible in dos but you did it.
Many thanks
