windows task manager script

I'm trying to figure out the best way to script for a specific process in the windows task manager (devenv.exe*), taskkill the process(s), and email the user name of each process killed. I would appreciate a push in the write direction. I'm not sure whether to split this in to 3 different batch files.
1. tasklist specific tasks to text file
2. taskkill from the list
3. email from the list

As i said, I would really appreciate some direction on this. I'm not really sure of the best way to proceed on this.

thank you.



Hi

Please look at Sysinternals Process Utilities - http://technet.microsoft.com/en-us/sysinternals/bb795533.aspx

PsKill
http://technet.microsoft.com/en-us/sysinternals/bb896683

PsList
http://technet.microsoft.com/en-us/sysinternals/bb896682



Hi

Please look at Sysinternals Process Utilities - http://technet.microsoft.com/en-us/sysinternals/bb795533.aspx

PsKill
http://technet.microsoft.com/en-us/sysinternals/bb896683

PsList
http://technet.microsoft.com/en-us/sysinternals/bb896682



right. I have the Sysinternals Utilities installed. Maybe PsKill and PsList offer more options than Taskkill and Tasklist. I'll do some comparing and see which is better.



I took care of this by using Tasklist and Taskkill in a simple .bat file.


echo off
tasklist /fi "imagename eq devenv.exe" /fi "username eq jones" |find ":" > nul > tasklistjones.txt
if errorlevel 1 taskkill /f /fi "imagename eq devenv.exe" /fi "username eq jones" blat tasklistjones.txt -t jones@email.com -s "Devenv.exe Processes with your username have been deleted. See text for details"
if errorlevel 0 blat tasklistjones.txt -t jeff.underwood@rainhail.com -s "Mindy Smith: No devenv.exe tasks are running which match your username."



I found the answer before i received any assistance and posted the result here in case someone else could use it.



Share this

Related Posts

There was an error in this gadget