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.
Asked
Active
Viewed 1,009 times
0
-
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
-
1what 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 Answers
1
You can launch from java a console commands, for example
Process p = Runtime.exec("taskkill /IM notepad.exe");
int exitValue = p.waitFor();
![](../../users/profiles/1309650.webp)
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
![](../../users/profiles/54506.webp)
Jayan
- 16,628
- 12
- 79
- 131