
批處理怎樣循環(huán)的檢測(cè)應(yīng)用程序狀態(tài)并重啟請(qǐng)教大家:我想寫一個(gè)批處理,循環(huán)的檢測(cè)應(yīng)用程序是否飛掉,記錄程序名,飛掉時(shí)間,并自動(dòng)重啟它,現(xiàn)在有幾個(gè)問(wèn)題向大家求助:1、為什么程序不會(huì)遍歷AppList.ini,也就是現(xiàn)在的程序只會(huì)檢測(cè) FoxMail.exe,而不會(huì)檢測(cè)QQ.exe的狀態(tài),并重啟。2、怎么替換現(xiàn)在命令中的 常量“Foxmail.exe” 字符,替換成 %%i 才是正確的吧。3、現(xiàn)在程序在異常時(shí),只記錄了時(shí)間,有沒(méi)有辦法紀(jì)錄其它的關(guān)鍵信息(內(nèi)存,CPU,,,)
nclick="copycode($('code0'));">復(fù)制代碼
- @echo off
- :1
- tasklist /nh>Tasklist.txt
- for /f delims=tokens=1 %%i in (AppList.ini) do (
- find /i %%i Tasklist.txt
- if ERRORLEVEL 1 (goto _T) else (goto _E)
- :_T
- echo foxmail.exe %date:~0,11%%time:~0,5%>>AppTime.txt
- start /min foxmail.exe.lnk
- :_E
- echo >nul
- )
- ping 127.1 -n 5 >nul 2>nul
- goto 1
- ::AppList.ini 樣式:foxmail.exe 換行 qq.exe

