Получить утилизация процессора по процессу
<Имя процесса> <Процент>
wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime | findstr /i /c:Rterm
@ECHO OFF
SET /A cpu_usage_1=0
SET /A cpu_usage_2=0
SET /A cpu_usage_3=0
SET /A cpu_usage_4=0
SET /A cpu_usage=0
for /f %%a in ('wmic path Win32_PerfFormattedData_PerfProc_Process where "Name = 'Rterm' and PercentProcessorTime < 1" get IDProcess') do (
SET /A cpu_usage_1=1
)
echo %cpu_usage_1%
timeout /t 2
for /f %%a in ('wmic path Win32_PerfFormattedData_PerfProc_Process where "Name = 'Rterm' and PercentProcessorTime < 1" get IDProcess') do (
SET /A cpu_usage_2=1
)
echo %cpu_usage_2%
timeout /t 2
for /f %%a in ('wmic path Win32_PerfFormattedData_PerfProc_Process where "Name = 'Rterm' and PercentProcessorTime < 1" get IDProcess') do (
SET /A cpu_usage_3=1
)
echo %cpu_usage_3%
timeout /t 2
for /f %%a in ('wmic path Win32_PerfFormattedData_PerfProc_Process where "Name = 'Rterm' and PercentProcessorTime < 1" get IDProcess') do (
SET /A cpu_usage_4=1
SET /A cpu_usage=%cpu_usage_1%+%cpu_usage_2%+%cpu_usage_3%+%cpu_usage_4%
If /I %cpu_usage% GEQ "3" (
for /f %%b in ("%%~a") do taskkill /F /pid %%~b
)
)
echo %cpu_usage_4%
echo %cpu_usage%