Code: Select all
@echo off
setlocal enabledelayedexpansion
netsh advfirewall show currentprofile |findstr /i "State" |findstr /i "ON" >nul
if "%ERRORLEVEL%"=="0" (
set "fRules=ON"
) else (
set "fRules=OFF"
)
echo %fRules%
pause > nul
pause 1>nul
If I remove the quotes in front of fRules, I get the following:
ON"
I have also tried IF %ERRORLEVEL% EQU 0 and the negation with IF %ERRORLEVEL% NEQ 0 to no avail. I would appreciate any advice.