问题
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