how to close currently created cmd.exe*32 and conhost.exe*32 using java code after execution of java program?

1.1k Views Asked by At

Actually i am running webobjects program through WOMonitor 5.4. If i execute program through WOMonitor then after instance up it creates two more exe (i.e. cmd.exe*32 and conhost.exe*32) that run in Task Manager as a process and it consumes more memory. For one instance it creates one cmd.exe*32 and conhost.exe*32 but on server i start 100 or 200 instance so create more cmd.exe*32 and conhost.exe*32. So please anybody help me.

Note: i want to see through java program that how many processes have been executed if i run a java program? If any method and java program any body has then please send me because this will help me.

1

There are 1 best solutions below

2
Andy Guibert On

You should be able do that with Runtime.exec(String command) by using the same type of commands that you would normally use to kill a process using Command Prompt.

Runtime.getRuntime().exec("taskkill cmd.exe*32");

If you want to check what processes are created, you could parse the command results of tasklist.

Program tasklist = Runtime.getRuntime().exec("tasklist");
InputStream programOutput = tasklist.getInputStream();
// parse programOutput in whatever way you want