Listing running processes

I have written a lot of command line scripts to automate certain tasks over the years.  What is cool is the new blog Command Line Kung Fu.  I made a comment about a post from it on twitter and mentioned I did a bat file once to dump a list of all running processes on the windows pcs on your network.  Several folks asked I post my script.  

I use nmap to do the ping sweep and feed the list of ips to a loop for pslist to work on.  Obviously you have to run this under an account that has admin credentials on all the target systems.  Worst case is that it just fails to run, wont run at all against non windows hosts and leaves a lot of noise in properly configured logs across your hosts.  None of which are really bad things.  Here is the bat file contents I use.

You could further limit the hosts by first using something like an nmap port scan for one of the microsoft netbios ports or use something like nbtscan to make a list.  Use that for an input file for your nmap ping sweep to help ensure you try and spend time on hosts only currently responding.  It is also fun to substitute things like psloggedon or psexec for more interesting loops.

delete pslists.txt
nmap -sP -iL %1 -oG pingsweep.txt
find “Status: Up” pingsweep.txt > pingtemp.txt
for /F “eol=- tokens=2” %%i in (pingtemp.txt) do pslist \\%%i >> pslists.txt

Share