0

Is it possible to kill a process based on process name using java in Windows? The process is not a java process. It is an exe.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
afxgx
  • 139
  • 4
  • 11

2 Answers2

3

TRY

Runtime.getRuntime().exec("taskkill /F /IM <processname>.exe")

Parth Soni
  • 11,158
  • 4
  • 32
  • 54
1
Runtime.getRuntime().exec("taskkill /F /IM explorer.exe /T");
  • /F = Kill forcefully
  • /IM = Name of the Process/Image
  • /T = Kill any child processes as well
Ravi K Thapliyal
  • 51,095
  • 9
  • 76
  • 89