简体   繁体   English

使用taskkill / F终止进程并返回代码0

[英]Killing a process with taskkill /F returning code 0

I need to kill a windows process (java.exe). 我需要杀死Windows进程(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) 我需要使用/ F选项,因为这是关键过程,但是通过这种方式,我得到的是返回码1,而我需要返回代码0(当我不使用/ F杀死其他非关键过程时返回)

how could I fix this problem? 我该如何解决这个问题?

Many thanks 非常感谢

You can try with : 您可以尝试:

TASKKILL /F /IM "notepad.exe"

You can know more here . 您可以在这里了解更多。 Visit this blog too. 也访问此博客

Why don't you use PowerShell? 您为什么不使用PowerShell?

Stop-Process -Name java.exe

From the old command prompt: 在旧的命令提示符下:

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

I am using following command on Windows Server 2008R2 我在Windows Server 2008R2上使用以下命令

Taskkill /IM B2B_Crawler_V2.exe /F

Refer Taskkill and Killing a process in Batch and reporting on success 批量引用Taskkill中止 进程并报告成功

Execute this in CMD 在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM