@echo off&setlocal enabledelayedexpansion
for /F "tokens=1,2" %%i in ('Tasklist /nh') do (call:hanye "%%i"
if !n! gtr 20 taskkill /f /pid %%j)
exit
:hanye
set "i=%~1"&set n=0
:guxing
if not "!i:~%n%,1!"=="" set/a n+=1&goto:guxing
Dos 脚本参考,无线延时,每隔1秒查找"calc.exe",如果找到就退出
for /L %%i in (1,1,0xFFFFFFFF) do (
ping 1.1.1.1 -n 1 -w 1000>NUL & for /f "tokens=1,2" %%p in ('tasklist /nh') do (if "%%p" =="calc.exe" taskkill /f /pid %%q & exit) )