I have a piece of code I want to use
reg query HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile /v EnableFirewall if %ERRORLEVEL% EQU 0 echo On
This will check if the firewall is enable if so it will echo "On". I try testing this command but my output is:
ERROR: Invalid syntax. Type "REG QUERY /?" for usage.
Does anybody knows how to let this code work?
Using for
you can do something like:
@echo off
for /f "tokens=3 delims= " %%i in ('reg query HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile /v EnableFirewall') do (
if "%%i" equ "0x1" (
echo activated
) else (
echo not activated
)
)