Это сценарий, который я использовал.
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
)