“Kill a process tree” on windows using Java

前端 未结 3 1067
闹比i
闹比i 2021-01-13 07:12

I have a Java webstart process that is part of a windows batch script. I\'m using the javaws command in a batch script in this case. This match script ( start.bat) is invoke

3条回答
  •  余生分开走
    2021-01-13 07:44

    Finally got something workable even though its a roundabout way.

    Apache Commons Exec API contains the CommandLauncher class that returns a java.lang.Process object. Thanks to the link

    Here the link to get the windows Process Id from a java.lang.Process. This uses the JNA libraries.

    Finally with the Process Id, here the command string that kills the process tree //String killCmd = "taskkill /F /T /PID " + JNAHandler.getPid(process);

提交回复
热议问题