Kill Processes





2
Date Submitted Thu. Mar. 2nd, 2006 3:51 AM
Revision 1 of 1
Syntax Master dannyboy
Tags "Command Line" | BATCH | CMD | KILL
Comments 0 comments
KillProc will do a search of all the current processes and kill all that
match the name given. If the process name is misspelled, KillProc would
kill itself, based on the match. The 'find /v /i "KillProc"' part of the
search prevents KillProc from killing the CMD window it is running in.

Requires NT Resourcekit

@Echo off
goto :MAIN

:USAGE
echo.
echo Usage:  KillProc ^[ ^<process name^> ^| ^</H^> ^]
echo.
echo   Kills all matches to the process name entered.
echo.
echo     Example: KillProc explorer
echo     Kills all EXPLORER.EXE processes.
echo.
echo   ^/H - Displays this help screen.
goto :eof

:MAIN
set FOUND=
if {%1}=={/h} goto :USAGE
if {%1}=={} goto :USAGE
for /f "tokens=1" %%i in ('tlist ^| find /i "%1" ^| find /v /i "KillProc"') do (
  kill %%i
  set FOUND=TRUE
  )
if not defined FOUND (
  echo Process not found.
  goto :USAGE
  )
 

Comments

There are currently no comments for this snippet.

Voting