监控控制台是否运行的bat
@echo off
rem
set secs=5
set srvname="TRS.Export.Scheduler.exe"
echo.
echo =====================================
echo == 查询计算机服务的状态, ========
echo == 每间隔%secs%秒钟进行一次查询 ===
echo == 如发现其停止,则立即启动。 ===
echo =====================================
echo.
echo 此脚本监控的服务是:%srvname%
echo.
if %srvname%.==.goto end
:RESTART
tasklist /FI "username eq administrator" | find /C "TRS.Export.Scheduler.exe" > C:\temp.txt
set /p num= < C:\temp.txt
del /F C:\temp.txt
echo %num%
if "%num%" == "0" start /D "D:\TRS.Export.JobApp\TRS.Export.Scheduler\bin" TRS.Export.Scheduler.exe
ping -n %secs% 127.0.0.1 > nul
goto RESTART
:end
posted on 2018-06-05 15:37 chengjunde 阅读(172) 评论(0) 编辑 收藏 举报