思路先用tasklist获得所有在运行的进程名,然后用for语句进行判断是否是要保留的进程:- @echo off
- echo 请输入你要保留的进程名,中间用空格格开
- set /p code=在此输入:
- for /f "delims=" %%a in ('tasklist^|findstr "exe"') do (
- for %%i in (%code% tasklist) do if /i "%%~na" neq "%%~ni" set "flag=a"
- if defined flag taskkill /im "%%a" /f>nul&set "flag="
- )
复制代码
|