王大

这世界不只眼前的苟且,还有诗与远方

导航

Windows 服务关闭自动重启

Posted on 2016-06-28 16:13  Cavalry  阅读(331)  评论(0编辑  收藏  举报
此方法可以用来监控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%"=="1" (
   echo Service "Print Spooler" restarted at %time% on %date% by Script %0>>c:\ServiceRestart.Log
   net start "Print Spooler"
)
2、创建任务计划,每隔1分钟执行以下第1步创建的bat