如何杀死所有同名进程并保存一个同名但使用精确 PID 的进程?



如何杀死所有名称为"OPCExplorer.exe"的进程,除了一个名为"OPCExplorer.exe"的进程,但例如PID = "8888"?

使用任务列表命令的过滤器:

@echo off

for /f "skip=3 tokens=2 delims= " %%a in ('tasklist /fi "imagename eq OPCExplorer.exe" /fi "PID ne 8888"') do (
taskkill /pid %%a /f
)

您可以使用内置WMIC.exe

WMIC Process Where "Name='OPCExplorer.exe' And Not ProcessId='8888'" Call Terminate

最新更新