bat 搜索进程名并kill
@echo off
set/p “target=进程名(默认nginx): “
if not defined target (
set “target=nginx”
)
set “list=tasklist /fi “imagename eq %target%.exe””
%list%
set/p “yn=是否继续Y/N(默认Y): “
set “Yy=Y y”
if not defined yn (
set “yn=Y”
)
for %%a in (%Yy%) DO (
if “%%a”==”%yn%” (
for /f “tokens=2 ” %%y in (‘%list% /nh’) do (
REM echo %%y
taskkill /F /PID %%y
)
)
)
set target=
set yn=
set Yy=
set list=
pause