windows服务守护进程bat脚本、windows窗体守护进程bat脚本
- window服务守护进程
@echo off rem 窗口标题 title "RabbitMQ-Daemons" rem 定义循环间隔时间(单位秒) set secs=60 rem 监测的服务名称 set srvname="RabbitMQ" rem 打印服务的名称 echo Daemons Server is : %srvname% if %srvname%. == . goto end :chkit set svrst=0 for /F "tokens=1* delims= " %%a in ('net start') do if /I "%%a %%b" == %srvname% set svrst=1 if %svrst% == 0 net start %srvname% set svrst= rem 下面的命令用于延时,否则可能会导致cpu单个核心满载。 ping -n %secs% 127.0.0.1 > nul goto chkit :end
windows窗体守护进程
@echo off title RabbitMQ-Daemons-exe rem 定义循环间隔时间和监测的服务: set secs=10 set exename="erlsrv.exe" set exepath="H:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.9\sbin\rabbitmq-service.bat" echo Daemons-exe is : %exename% if %exename%. == . goto end :chkit set svrst=0 for /f %%i in ('tasklist') do if /I "%%i" == %exename% set svrst=1 rem 如果不是管理员就无法启动 if %svrst% == 0 start "" %exepath% start taskkill /f /im cmd.exe set svrst= rem 下面的命令用于延时,否则可能会导致cpu单个核心满载。 ping -n %secs% 127.0.0.1 > nul goto chkit :end
转: https://blog.csdn.net/qq_18671415/article/details/111640477
https://blog.csdn.net/star8521/article/details/121188971