0

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" 

================================

2
  • Do you have grep under windows? Commented Jan 17, 2014 at 19:39
  • Please edit your code for readability. E.g. indent any code by four spaces. Then, it is highlighted in gray. Commented Jan 17, 2014 at 19:51

1 Answer 1

1

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
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.