Command as shown below:
C:\>iisreset /status
Status for World Wide Web Publishing Service ( W3SVC ) : Stopped
Status for Simple Mail Transfer Protocol (SMTP) ( SMTPSVC ) : Stopped
Status for Windows Remote Management (WS-Management) ( WinRM ) : Stopped
Status for HTTP SSL ( HTTPFilter ) : Running
I'm trying to develop a code that has the status of values in the variables below:
- W3SVC: Stopped
- SMTP: Stopped
- WinRM: Stopped
- HTTPFilter: Running
But I am not able to develop a code. Somebody help me with the code below:
Code: Select all
setlocal enabledelayedexpansion
set "cn="
set "status="
for /f "tokens=1,2 delims=:" %%f in ('IISRESET /STATUS') do (
set "cn=%%f"&"status=%%g"
if defined cn (
set "W3SVC="
set "SMTP="
set "WinRM="
set "HTTPFilter="
for /f "delims=" %%k in ('echo !cn! ^| findstr W3SVC') do set "W3SVC=%%k"
if defined W3SVC (
set W3SVC=%status%
)
)
)
echo W3SVC=%W3SVC%
echo SMTP=%SMTP%
echo WinRM=%WinRM%
echo HTTPFilter=%HTTPFilter%