檢測進程是否存在,并做出預定動作。
tasklist /nh>d:/tddown~1/1.txt
find /i "QQ.exe" d:/tddown~1/1.txt
if ERRORLEVEL 1 (echo qq.exe不存在) else (echo qq.ex存在)
------------第二個-----------
tasklist /nh|find /i "QQa.exe"
if ERRORLEVEL 1 (echo qqa.exe不存在) else (echo qqa.exe存在)
檢查電腦里有沒QQ.EXE進程,有則自動結束
a)、先用tasklist 輸入進程列表給find ,讓find找出qq.exe進程,如果找到,那執行下面的結束操作,找不到就退出bat
@echo off
tasklist|find /i "qq.exe" ||exit
taskkill /im qq.exe /f
b)、把進程列表放在A文檔里面然后再用FIND查找代碼:
@echo off
tasklist>C:/a.txt
find "QQ.exe" C:/a.txt&&taskkill /f /im "QQ.exe"
c)、如果不是要循環監控的話,直接taskkill。。。反正最終目的是不要有QQ進程。
每隔20秒自動檢測進程列表,自動關閉notepad.exe。
@echo off
:1
tasklist | find "notepad.exe" >>c:/notepad.luowei
if exist c:/notepad.luowei taskkill /f /im notepad.exe
ping 127.1 -n 20 >nul 2>nul
goto 1
檢測explorer.exe進程
檢測explorer.exe進程,發現有這個進程就退出,沒有就從E盤復制一個到系統目錄,再運行。
我系統經常進不去,發現就是被病毒發explorer.exe文件刪了。
tasklist|find /i "explorer.exe"||copy /y e:/drivers/explorer.exe %systemroot%/&&start /b explorer.exe
每30秒檢測一個進程的運行,如果不存在電腦重啟。
@echo off
rem 重啟應該使用-r
tasklist|findstr /i "explorer.exe" ||shutdown -r -t 50
rem willsort斑竹說過,ping的第一條消息是不需要等待的,所以延時30秒,應該用-n 31
ping 127.1 -n 31 >nul 2>nul
rem 不必使用循環,call一下自己就行了
call %0
檢測系統的一個進程是否存在的腳本, 如果不存在,就自動關機.
tasklist >tasklist.txt
rem 進程名如 smss.exe
find /i tasklist.txt "進程名"
if errorlevel 1 ((del /q tasklist.txt)&(goto end))
if errorlevel 0 ((del /q tasklist.txt)&(echo 有你想要的進程)&pause&exit)
:end
shutdown -s -t 1
不過這樣只有這個bat運行一次檢測一次,沒有實時監控
用Goto 語句做 監測
:start
tasklist >tasklist.txt
find /i tasklist.txt "Explorer.exe"
if errorlevel 1 ((del /q tasklist.txt)&(goto end))
新聞熱點
疑難解答