Created
September 4, 2012 06:58
-
-
Save brymck/3617816 to your computer and use it in GitHub Desktop.
Kill off a Java process with better information than what Task Manager gives you
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem List all running Java processes, excluding useless metrics | |
tasklist /fi "IMAGENAME eq javaw.exe" /fo LIST /v ^ | |
| find /v "Session" ^ | |
| find /v "User" ^ | |
| find /v "CPU" ^ | |
| find /v "Status" | |
echo. | |
:user_input | |
rem Ask for user input, exiting quietly if nothing is provided | |
set /p process_id=Enter a process ID (leave blank to quit): | |
if "%process_id%" equ "" goto leave_alone | |
rem Make sure that the PID is a positive number | |
set /a pid_number=%process_id% | |
if %pid_number% leq 0 goto invalid_input | |
rem Kill off process, force-quitting if necessary | |
echo. | |
echo Killing process #%process_id%... | |
taskkill /f /pid %process_id% | |
echo. | |
pause | |
goto eof | |
:leave_alone | |
echo You may live... for now. | |
goto eof | |
:invalid_input | |
echo Invalid input. You must enter a number greater than 0. | |
echo. | |
goto user_input | |
:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment