- @echo off
- title %~n0
- for /f "skip=3 tokens=2" %%a in ('TASKLIST /FI "WINDOWTITLE eq %~n0" /FI "STATUS eq running"') do set pcmd=%%a
- set /p "vard=允许运行进程【如:QQ.exe IEXPLORE.EXE】:"
- :a
- cd.>%temp%_npslist.txt
- for /f "skip=3 tokens=1,2" %%a in ('tasklist') do echo %%a %%b|findstr /i /v "System smss.exe csrss.exe winlogon.exe services.exe lsass.exe svchost.exe conime.exe explorer.exe wmiprvse.exe Userinit.exe taskkill.exe spoolsv.exe ctfmon.exe alg.exe tasklist.exe %vard%">>%temp%_npslist.txt
- for /f "tokens=1,2" %%a in (%temp%_npslist.txt) do (
- set ovar=%%a&&if not defined ovar goto b
- if /i "%%a"=="cmd.exe" (if not %%b==%pcmd% taskkill /f /t /pid %%b) else (taskkill /f /t /im %%a||NTSD -c q -P %%a)
- )
- :b
- del %temp%_npslist.txt>nul 2>nul
- ping /n 5 127.0.1>nul
- goto a
-
复制代码
[ 本帖最后由 cjiabing 于 2010-10-6 17:14 编辑 ] |