Reputation: 1
I want to modify the below script to give me out put like
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
Please can someone help?
===============================
@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"
================================
Upvotes: 0
Views: 314
Reputation: 1658
You can use the filter if IMAGENAME command to give you just the necessary processes. I used a for command because output of IMAGENAME behaves strange...it is always displayed at the beginning of the line.
@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
)
Upvotes: 1