@ECHO OFF :: Keep variables local SETLOCAL :: Explain usage if no parameter was given. IF "%1"=="" GOTO Syntax IF "%1"=="?" GOTO Syntax IF "%1"=="-?" GOTO Syntax IF "%1"=="/?" GOTO Syntax :: Initialize main variable. SET PID= :: Display which process is about to get killed. :: Lines with CMD.EXE are filtered out, because otherwise :: this batch file might accidently kill itself later. TLIST | FIND /I " %1 " | FIND /I /V "CMD.EXE" :: Ask confirmation unless /Y parameter was specified. IF /I "%2"=="/Y" GOTO SkipConfirm ECHO Are you sure you want to kill this process? ECHO If not, press ^C (Ctrl+C), otherwise PAUSE :SkipConfirm :: Find the process ID for the specified program FOR /F "tokens=1*" %%A IN ('TLIST ^| FIND /I " %1 " ^| FIND /I /V "CMD.EXE"') DO SET PID=%%A :: Kill the process by its process ID. KILL %PID% GOTO End :Syntax :: Display help screen CLS ECHO KILLNTPR.BAT, Version 2.11 ECHO KILL NT PRocess ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com ECHO. ECHO Usage: KILLNTPR program_name [ /Y ] ECHO. ECHO program_name is the file name of the executable ECHO with extension but without path ECHO. ECHO /Y if specified, no confirmation is required ECHO. ECHO This batch file uses some utilities from the MS Windows NT Resource Kit. ECHO It will not function without this Resource Kit. :End ENDLOCAL