0

Is there a way I can stop all processes in a certain directory through Java? I need my java program to stop all processes in directory "X" on my C:\ drive.

BinaryShrub
  • 306
  • 1
  • 3
  • 14
  • You might find this link useful. http://stackoverflow.com/questions/81902/how-to-find-and-kill-running-win-processes-from-within-java –  Apr 06 '12 at 03:43
  • 1
    what is the meaning of 'processes' in a directory? All process which has open handles to 'directory'? – Jayan Apr 06 '12 at 03:44
  • Do you mean all processes whose executables live in a particular directory? All processes whose current directory is set to a particular directory? Something else? – Harry Johnston Apr 06 '12 at 04:44

2 Answers2

1

You can launch from java a console commands, for example

Process p = Runtime.exec("taskkill /IM notepad.exe");
int exitValue = p.waitFor();
dash1e
  • 7,289
  • 1
  • 26
  • 34
0

There are suite of tools from sysinternals. You can query processes and take actions on them. well there is not much to do with Java.

See some info on handles

Jayan
  • 16,628
  • 12
  • 79
  • 131