@echo off
:checkservice
for /f "tokens=5" %%n in ('qprocess.exe ^| find "supernode.exe" ') do (
if %%n==supernode.exe ( goto checkmessage) else ( goto restartservice))
:restartservice
echo %time%
echo ********程式開始啟動********
echo 程式重新啟動於%time% ,請檢查系統日誌 >> restart_service.txt
echo start c:\users\administrator\desktop\ccol4w-build\runn2nsupernode.bat > start.bat
echo exit >> start.bat
start start.bat
rem set /p=.nul
echo .
del start.bat /q
echo ********程式啟動完成********
goto checkservice
:checkmessage
echo %time% 程式執行正常,30秒後繼續檢查..
ping localhost -n 30> nul
goto checkservice
其中紅色部分修改為監控的程序名,綠色則是程式或指令碼的啟動位置. windows下bat批處理實現守護程序
最近幾天加班加瘋掉了,天天晚上沒法睡。開發部的乙個核心程式總是會自己宕機,然後需要手工去起,而這個服務的安全級別又很高,只有我可以操作,搞得我晚上老沒法睡,昨晚實在受不了了,想起以前在hp ux下寫的shell守護程序,這回搞個windows下的bat版守護程式吧,當時晚上思路已經很遲鈍了,就叫了個...
windows下bat批處理實現守護程序
最近幾天加班加瘋掉了,天天晚上沒法睡。開發部的乙個核心程式總是會自己宕機,然後需要手工去起,而這個服務的安全級別又很高,只有我可以操作,搞得我晚上老沒法睡,昨晚實在受不了了,想起以前在hp ux下寫的shell守護程序,這回搞個windows下的bat版守護程式吧,當時晚上思路已經很遲鈍了,就叫了個...
Bat 指令碼實現監控程序功能
指令碼不間斷監控notepad.exe,若停止,則自動重啟,程式如下 echo off set task notepad.exe set svr c windows notepad.exe set des start.bat checkservice for f tokens 5 n in qpro...