我正在尝试根据此语句输出执行操作:
wmic process where name="test.exe" | find "test.exe" /c
if the output is <=2 do echo two or less
if the output is >2 do echo more than two
如何实现这一目标?
答案 0 :(得分:2)
将它们设置为变量,然后在搜索字符串= D
之前比较您想要的开关FOR /F "tokens=2 USEBACKQ delims=:" %%F IN (`command ^| find /C "test.exe"`) DO (
SET var=%%F
)
IF %var% LEQ 2 ECHO Two or Less
IF %var% GTR 2 ECHO More than Two
编辑:(对于Jeb&lt; 3)
FOR /F "tokens=2 USEBACKQ delims=:" %%F IN (`command ^| find /C "test.exe"`) DO (
SET var=%%F
)
IF %var% LEQ 2 (
ECHO Two or Less
) ELSE (
ECHO More than Two
)