Windows 服务关闭自动重启

时间:2022-02-21 09:25:03
此方法可以用来监控Windows Service是否运行良好

1、创建批处理程序,判断服务是否启动,若未启动则启动之
@echo off
Rem Look for the Print Spooler service in the list of started services
net start | find /i "Print Spooler"
Rem if not found, start it and a restart occurred.
if "%errorlevel%"=="" (
echo Service "Print Spooler" restarted at %time% on %date% by Script %0>>c:\ServiceRestart.Log
net start "Print Spooler"
)
2、创建任务计划,每隔1分钟执行以下第1步创建的bat