windows - How to use a batch file to check WinService Status? -
i created winservice , set start , stop on scheduled tasks. everyday after service started 20 seconds, automatically stops without alert though in scheduled task did setup re-starting if starting fails. therefore, have re-start service manually everyday morning. now, want write batch file can implement following tasks:
- check winservice running
- if not in 1), start service
- write record 1) , 2).
appreciate if can provide walk-through procedure it.
@echo off set "sevice_name=winservice" sc query "%sevice_name%" | find /i "running" || ( echo service "%sevice_name%" stopped sc start "%sevice_name%" goto :end ) >> log.txt :end echo service "%sevice_name%" running >> log.txt
Comments
Post a Comment