@ECHO OFF :: KILLNTPR.BAT, Version 1.03 :: KILL NT PRocess by its executable file name :: Written by Rob van der Woude :: http://www.robvanderwoude.com :: Dependencies: [1] MS Windows NT Resource Kit :: [2] ENGLISH version of NT :: 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 "%2"=="/Y" GOTO SkipConfirm IF "%2"=="/y" GOTO SkipConfirm ECHO Are you sure you want to kill this process? ECHO If not, press ^C (Ctrl+C), otherwise PAUSE :SkipConfirm :: Redirect the line we just displayed to a temporary batch file. :: By first feeding the line to TIME, we make sure the displayed :: line will be preceded by a fixed string (Enter the new time:), :: which makes it easier to store the FIRST word in the line (the :: process ID) in an environment variable PID. TLIST | FIND /I " %1 " | FIND /I /V "CMD.EXE" | TIME | FIND /I "%1" > TEMP.BAT :: Create another temporary batch file, ENTER.BAT. :: IMPORTANT: The string "Enter the new time:" is, of course, :: language dependant, so modify and rename this batch :: file accordingly if you use a non-English NT version. > ENTER.BAT ECHO @ECHO OFF >> ENTER.BAT ECHO SET PID=%%4 :: Now call TEMP.BAT, which in turn call ENTER.BAT, which sets the :: value of environment variable PID to the wanted process ID. CALL TEMP.BAT :: Kill the process by its process ID. KILL %PID% :: Clean up the mess. DEL ENTER.BAT DEL TEMP.BAT SET PID= :: And quit. GOTO End :Syntax :: Display help screen CLS ECHO KILLNTPR.BAT, Version 1.03 ECHO KILL NT PRocess ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com ECHO. ECHO Usage: KILLPRNT 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. :: Modify or remove the next command line if you :: adapted this batch file to any other language. ECHO This batch file was written for English NT versions only. :End