@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
set /p=.<nul
for /L %%i in (1 1 10) do set /p a=.<nul & ping.exe /n 2 127.0.0.1>nul
echo .
del start.bat /Q
echo ********程序启动完成********
goto checkService
:checkMessage
echo %time% 程序运行正常,30秒后继续检查..
ping localhost -n 30> nul
goto checkService
其中红色部分修改为监控的进程名,绿色则是程序或脚本的启动位置.