如何通过Windows cmd中的进程ID来终止Java应用程序?

问题描述:

当我运行命令:taskkill /f /pid 16140如何通过Windows cmd中的进程ID来终止Java应用程序?

我得到这个:ERROR: The process "16140" not found.

+0

如何知道pid是16140? –

+1

A)这不是一个Java问题B)如何获得该PID号码?你看,可能这个数字是错的? – GhostCat

+0

你应该问[这里](https://superuser.com/questions/ask)。 –

右击NameTask Manager,检查PID展现的过程PID,然后执行taskkill /pid {PID}
请注意,某些进程无法以taskkill终止,例如任务管理器。

enter image description here

taskkill /im myprocess.exe /f 

的 “/ F” 是 “力量”。如果你知道的PID,那么你可以指定,如:

taskkill /pid 1234 /f 

很多其他的选择都是可能的,只要键入taskkill /?为他们所有。 “/ t”选项杀死进程和任何子进程;这可能对您有用

您可以通过进程ID(PID)或映像名称(EXE文件名)来终止进程。

打开一个行政级别的命令提示符,然后运行任务列表来查看所有正在运行的进程:

C:\>tasklist 

Image Name      PID Session Name  Mem Usage 
========================= ======== ================ ============ 
firefox.exe     26356 Console    139,352 K 
regedit.exe     24244 Console    9,768 K 
cmd.exe      18664 Console    2,380 K 
conhost.exe     2528 Console    7,852 K 
notepad.exe     17364 Console    7,892 K 
notepad.exe     24696 Console    22,028 K 
notepad.exe     25304 Console    5,852 K 
explorer.exe     2864 Console    72,232 K 

在上面的例子中,你可以看到图像的名称和PID为每个进程。如果你想杀死Firefox进程运行:

C:\>Taskkill /IM firefox.exe /F 

C:\>Taskkill /PID 26356 /F 

/f标记是强行终止进程。不使用/ F标志在某些情况下不会导致任何事情发生。一个例子是每当我想杀死explorer.exe进程时,我必须使用/ F标志,否则进程不会终止。