Kill JVM not forcibly from command line in Windows 7

吃可爱长大的小学妹 提交于 2019-12-10 10:06:01

问题


I have Cobertura instrumented jar running in JVM. When I press Ctrl-C in Windows console, where application runs, JVM ends and Cobertura results are successfully flushed to cobertura.ser file. But I need stop this JVM with command/tool (not Ctrl-C), something like "soft kill" in Linux ("kill" command without "-9" parameter). When I use "taskkill /PID 1234", it writes:

D:\>taskkill /PID 1234
ERROR: The process with PID 1234 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).

But when I use parameter /F, JVM is terminated forcibly and that is why Cobertura results are not flushed to cobertura.ser file.

How to kill JVM using Windows command/third party tool with successful Cobertura flush (windows "soft kill")?


回答1:


Try look at WMI, using JavaScript or VBScript you create rules for selecting process and killing it.

For example http://community.spiceworks.com/scripts/show/498-kill-a-process-using-wmi - enlist simple kill script using VBScript



来源:https://stackoverflow.com/questions/14952948/kill-jvm-not-forcibly-from-command-line-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!