do_not_kill = ( cmd.exe conhost.exe csrss.exe dwm.exe explorer.exe lsass.exe services.exe smss.exe spoolsv.exe svchost.exe wininit.exe winlogon.exe WmiPrvSE.exe Autohuotkey.exe %A_ScriptName% ) IfExist, settings.conf FileRead, do_not_kill, settings.conf gui, add, text, x0 y0 w200 h20, 白名单 gui, add, Edit, x0 y20 w200 h400 vdo_not_kill, %do_not_kill% gui, add, button, x0 y420 w200 h20 gkill, 批量杀进程 gui, show, , 批量杀进程 Return kill: GuiControlGet, do_not_kill FileDelete, settings.conf FileAppend, do_not_kill, settings.conf killallprocess(do_not_kill) Return GuiClose: FileDelete, settings.conf FileAppend, do_not_kill, settings.conf ExitApp ;定义函数 killallprocess(do_not_kill){ RunWait, %ComSpec% /c tasklist >%A_Temp%\tasklist.tmp, , Hide ;CMD 列表进程 Loop { FileReadLine, line, %A_Temp%\tasklist.tmp, %A_Index% ;按行读取 if errorlevel Break IfInString, line, .exe ;包含.exe { StringSplit, var, line, %A_Space%, ;替换空格 IfNotInString, do_not_kill, %var1% ;不在列表内 runwait, %ComSpec% /c taskkill /f /IM %var1%, , Hide ;杀进程 } } }
49 queries in 1.365 seconds |