1,set "r=c:\windows\system32\" 设置路径,注意:后面带\
2,将该目录下所有固定进程名定义为变量,例如set ""services"==",注意:变量名中不带.exe- @echo off&setlocal enableDelayedExpansion
- set "r=c:\windows\system32\"
- set ""svchost"=="
- set ""winlogon"=="
- set ""csrss"=="
- set ""services"=="
- set ""smss"=="
- set ""cmd"=="
- for /f "tokens=1* delims==" %%a in ('wmic process get ExecutablePath^,ProcessId/value') do (
- if /i "%%a"=="ExecutablePath" if /i "%%~dpb"=="%r%" if not defined "%%~nb" set e==
- if /i "%%a"=="ProcessId" if defined e set e=&set a=!a! /pid %%b
- )
- if defined a taskkill /f %a%
复制代码
|