我想对每30秒运行的红宝石处理进行计数,如果计数发生变化,请用“ OH NO!”提醒我。最好。谢谢大家!
但是我什至无法使它工作……不等于50
FOR /F "delims=" %%G IN ('tasklist ^|find /I /C "ruby.exe"')do set count=%%G
IF "%%G"=="50" ECHO OH NO!
timeout /t 10
答案 0 :(得分:0)
您试图设置count变量,但是尽管它仍然是错误的,但是您从未尝试使用它,因此让我们正确设置它并实际使用count:
for /f "tokens=1,*" %%a in ('tasklist ^| find /I /C "ruby.exe"') do set count=%%a
if "%count%" equ "50" echo Oh No.
timeout /t 10
要匹配先前的变量,我们只保存变量1,在30秒后再次运行检查,并在循环中比较2个变量。
@echo off
:start
set count=
set count2=
for /f "tokens=1,*" %%a in ('tasklist ^| find /I /C "ruby.exe"') do set count=%%a
timeout /t 30
for /f "tokens=1,*" %%i in ('tasklist ^| find /I /C "ruby.exe"') do set count2=%%i
if "%count%" equ "%count2%" (
cls
echo Count the same
goto :start
) else (
cls
echo Current count %count2% has changed from %count%
pause
)