0

I need a script to check the status of multiple services in a single server and the status of the services should be displayed in a consolidated format in a single text file and a mail needs to be send to the concerned people in a specified time as well.

Can anyone help me with this?

1 Answer 1

0

This is the script I used.

Echo Off
Setlocal EnableDelayedExpansion
IF EXIST Result.csv DEL Result.csv
FOR /F "Tokens=*" %%L IN (Servers.txt) DO (
   SET ServerName=
   SET ServerName=%%L
   SC.exe \\!ServerName! Query MapGenServer > Result.txt

SC.exe \\!ServerName! Query MECServer > Result1.txt
)
Find /i "RUNNING" < Result.txt
IF !ErrorLevel! == 0 (
    Echo !ServerName!, Running >> Result.txt
) ELSE (
    Echo !ServerName!, Not Running >> Result.txt

Find /i "RUNNING" < Result1.txt
IF !ErrorLevel! == 0 (
    Echo !ServerName!, Running >> Result1.txt
) ELSE (
    Echo !ServerName!, Not Running >> Result1.txt
)
1
  • 4
    If you are going to write an answer to your own question please format it correctly, and add some explanation as to how it works. Code only answers do not help future readers.
    – DavidPostill
    Sep 5, 2018 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .