Home > OS >  Windows8.1 want to use the batch achieve a daemon, to monitor several services, if stopped will enab
Windows8.1 want to use the batch achieve a daemon, to monitor several services, if stopped will enab

Time:10-24

Windows8.1 want to use the batch achieve a daemon, to monitor several services, if stopped will enable service, according to online data achieved, but only for a service, how to use the batch to monitor several services? (similar to cycle in the c + + statements, it is "service name" in the following example is variable, instead of writing to death), batch write less, not going to happen, below is my according to online data change, want to at the same time for multiple service implementations,

@ echo off

: checkstart
3 tokens for/f "skip==4" % % I in (' sc query service name), do the set "zt=% % I" & amp; Goto: next
: next
If/I "zt % %==" "RUNNING" (goto checkag)
If/I zt "% %"=="STOPPED" (goto startsvr)

: startsvr
The echo time % %
Echo * * * * * * * * service to start * * * * * * * *
Echo service restart % % time, please check the system log & gt;> Restart_service. TXT
Sc config service name start=AUTO
Sc start service name

The set/p=. & lt; Nul
For/L % % I in (1, 1) do the set/p a=. & lt; Nul& Ping. Exe/n 2 127.0.0.1 & gt; Nul
Echo.
Echo Wscript. Sleep Wscript. The Arguments (0) & gt; TMP % % \ delay. The VBS
Cscript TMP////nologo b % % \ delay. The VBS 10000
Echo * * * * * * * * service start complete * * * * * * * *
Goto checkstart

: checkag
The echo time % % service running normally, after 10 seconds to continue to check..
Echo Wscript. Sleep Wscript. The Arguments (0) & gt; TMP % % \ delay. The VBS
Cscript TMP////nologo b % % \ delay. The VBS 10000
Goto checkstart

CodePudding user response:

Strives for the great god, in my best to change the above example, online, etc

CodePudding user response:

Can't set loop statement, repeat it

CodePudding user response:

How to set the @ paqie7201?
  • Related