1.

Solve : Print running processe to txt file?

Answer»

Hi all

Im trying to list the process count or if it is running (IEXPLORE.EXE) process and pipe the output to a txt file. Below is the code I have for now...

Code: [Select]@echo OFF

for /f "tokens=1" %%a in (myList.txt) do (
ECHO -----------------------------------------
ECHO %%a
ECHO -----------------------------------------
ECHO Searching for process... %%a
start rclient %%a /R "c:\temp\tasklist /v /fi "IMAGENAME EQ IEXPLORE.exe" > c:\temp\process.txt"
REM

)

Seems when I run the batch file it creates the file but NOTHING is recorded to the file e.g. blank when opening.

When I run the command manually it WORKS OK and the output below is what I d like it to write to the txt file?

Code: [Select]C:\Scripts\tasklist /m /fi "IMAGENAME EQ IEXPLORE.exe"

Image Name PID Modules
========================= ===============
IEXPLORE.EXE 6920 kernel32.dll

Could anyone help to make it write to the file to say something like no running process found or if the process is found to write it to the file what the output is above?

Have you verified that rclient is executing successfully?
Quote from: oldun on August 09, 2009, 10:43:14 PM

Have you verified that rclient is executing successfully?


Yes rclient is executing correctly.Try REMOVING the quotes surrounding the tasklist command. i.e. change

start rclient %%a /R "c:\temp\tasklist /v /fi "IMAGENAME EQ IEXPLORE.exe" > c:\temp\process.txt"

to

start rclient %%a /R c:\temp\tasklist /v /fi "IMAGENAME EQ IEXPLORE.exe" > c:\temp\process.txt

One other thing I noticed, in your batch file you are calling tasklist from c:\temp\ and when running from the command prompt you are calling tasklist from C:\Scripts\!
Quote from: oldun on August 10, 2009, 01:21:14 AM
Try removing the quotes surrounding the tasklist command. i.e. change

Tried that one and I get the following message after removing the quotes "The system cannot find the path specified."

Quote from: oldun on August 10, 2009, 01:21:14 AM
One other thing I noticed, in your batch file you are calling tasklist from c:\temp\ and when running from the command prompt you are calling tasklist from C:\Scripts\!

The script is being from a local MACHINE to retrieve the required info from about twenty machines in the domain group. The myList.txt contains machine list.

Thanks for the asisstance CH contributors on this one. Even though it wasnt a few lines I wrote a SQL script to do what I needed. Solved.


Discussion

No Comment Found