您好,欢迎来到华拓科技网。
搜索
您的当前位置:首页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 ('qprocess.exe ^| find "%_task%" ') do (
    if %%n==%_task% (goto checkMessage) else goto restartService
)
  
:restartService
echo %time% 
echo ********程序开始启动********
echo 程序重新启动于 %time% ,请检查系统日志 >> restart_service.txt
echo start %_svr% > %_des%
echo exit >> %_des%
start %_des%
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 %_des% /Q
echo ********程序启动完成********
goto checkService
 
 
:checkMessage
echo %time% 程序运行正常,5秒后继续检查.. 
ping localhost -n 5 
goto checkService

转载于:https://www.cnblogs.com/Mu-qin/p/110910.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo6.cn 版权所有 赣ICP备2024042791号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务