I am adding a windows firewall rule using netsh advfirewall firewall command in a setup program. My code is giving an error message if the system has windows firewall disabled.
So I need to check the window's firewall status before executing the command netsh advfirewall firewall add. ie, if firewall is disabled, no need to add the rule.
I am checking if the firewall is enabled or not by using the window registry value "EnableFirewall".
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile
I am not sure this is the right way. There can be domain firewall profile(?) also.
Thanks in advance.
To check the status of Windows Firewall: Netsh Advfirewall show allprofiles.
Another option is to use netsh
itself to check if firewall is enabled or not. Execute the command netsh advfirewall show private|public|domain
. It will give the state on/off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With