Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop process started with an Eclipse external tools configuration

I have a Windows .bat file that starts a java program. For the sake of convenience I have created an Eclipse external tools configuration to start it directly from the IDE and to read its standard output from the Eclipse console.

However, when I terminate the process from Eclipse with the terminate button (the red square) in the Console view, the program is still running.

How to kill it from Eclipse (without creating a separate launch configuration that will search it and kill it programmatically)?

like image 736
Dragan Bozanovic Avatar asked Mar 04 '16 18:03

Dragan Bozanovic


1 Answers

You should use this command TASKKILL

Syntax TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]

Options /S system The remote system to connect to.

/U   [domain\]user    The user context under which
                      the command should execute.

/P   [password]       The password. Prompts for input if omitted.

/F                    Forcefully terminate the process(es).

/FI  filter           Display a set of tasks that match a
                      given criteria specified by the filter.

/PID process id       The PID of the process to be terminated.

/IM  image name       The image name of the process to be terminated.
                      Wildcard '*' can be used to specify all image names.

/T                     Tree kill: terminates the specified process
                       and any child processes which were started by it.

Filters Apply one of the Filters below:

         Imagename   eq, ne                  String
         PID         eq, ne, gt, lt, ge, le  Positive integer.
         Session     eq, ne, gt, lt, ge, le  Any valid session number.
         Status      eq, ne                  RUNNING | NOT RESPONDING
         CPUTime     eq, ne, gt, lt, ge, le  Time hh:mm:ss
         MemUsage    eq, ne, gt, lt, ge, le  Any valid integer.
         Username    eq, ne                  User name ([Domain\]User).
         Services    eq, ne                  String The service name
         Windowtitle eq, ne                  String
         Modules     eq, ne                  String The DLL name

Examples:

TASKKILL /S system /F /IM notepad.exe /T
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM notepad.exe /IM mspaint.exe
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

This is an example named : ProcessKiller.bat :

To kill differents process like eclipse.exe and javaw.exe at once and log the result into a logfile for success or failure !

@echo off
cls & color 0A
Mode con cols=50 lines=6
Title ProcessKiller by Hackoo 2016
set process="eclipse.exe" "javaw.exe"
set Tmp=Tmp.txt
set LogFile=ProcessKillerLog.txt
If Exist %Tmp% Del %Tmp%
If Exist %LogFile% Del %LogFile%
For %%a in (%process%) Do Call :KillMyProcess %%a %Tmp%
Cmd /U /C Type %Tmp% > %LogFile%
If Exist %Tmp% Del %Tmp%
Start "" %LogFile%
Exit /b

:KillMyProcess
Cls 
echo.
ECHO     **************************************
Echo          Trying to kill "%~1"
ECHO     **************************************                       
(
Echo The Process :  "%~1"  
Taskkill /IM  "%~1" /F /T
Echo =======================
)>>%2 2>&1

If you want to kill all java.exe processes : Taskkill /F /IM java.exe /T or wmic process where "name like '%java%'" delete

like image 119
Hackoo Avatar answered Oct 20 '22 22:10

Hackoo