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