我想修改下面的脚本,让我像
一样Number of processes on machine1 are 1
Number of processes on machine2 are 3
Number of processes on machine3 are 7
Number of processes on machine4 are 2
请有人帮忙吗?
===============================
@echo off
setlocal enabledelayedexpansion
pushd "%~dp0"
echo %date% %time%
TASKLIST /S machine1 | grep -c "process"
TASKLIST /S machine2 | grep -c "process"
TASKLIST /S machine3 | grep -c "process"
TASKLIST /S machine4 | grep -c "process"
================================
答案 0 :(得分:1)
如果使用IMAGENAME命令,您可以使用过滤器为您提供必要的过程。 我使用了for命令,因为IMAGENAME的输出表现很奇怪......它总是显示在行的开头。
@echo off
set compName1=machine1
for /f %%a in ('tasklist /NH /FO CSV /FI "IMAGENAME eq process" ^| find /C /V ""') do (
echo Number of processes on %compName1% are %%a
)