Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check window's firewall is enabled or not using commands

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.

like image 323
JChan Avatar asked Jul 05 '12 19:07

JChan


People also ask

What is the command to check the firewall status?

To check the status of Windows Firewall: Netsh Advfirewall show allprofiles.


1 Answers

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.

like image 68
Pr38y Avatar answered Oct 12 '22 20:10

Pr38y