Killing a process with taskkill /F returning code 0

谁说我不能喝 提交于 2019-12-12 18:18:17

问题


I need to kill a windows process (java.exe). I'm currently using:

taskkill.exe /F /IM java.exe

I need to use the /F option since is a critical process,but in this way I get a return code 1 instead I need a return code 0 (returned when I don't use /F for killing other not critical processes)

how could I fix this problem?

Many thanks


回答1:


You can try with :

TASKKILL /F /IM "notepad.exe"

You can know more here. Visit this blog too.




回答2:


Why don't you use PowerShell?

Stop-Process -Name java.exe

From the old command prompt:

powershell -Command "Stop-Process -Name java.exe"



回答3:


I am using following command on Windows Server 2008R2

Taskkill /IM B2B_Crawler_V2.exe /F

Refer Taskkill and Killing a process in Batch and reporting on success




回答4:


Execute this in CMD

Get the list of open processes

netstat -a -o -n

And then kill the process on that port with the following command

taskkill /F /PID <pid>


来源:https://stackoverflow.com/questions/3151314/killing-a-process-with-taskkill-f-returning-code-0

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