HNetCfg.FwPolicy2 firewall quickie

Started by stanl, September 09, 2020, 12:30:13 PM

Previous topic - Next topic

stanl

Code (WINBATCH) Select


;Winbatch - find open firewall ports
;===============================================================================================
firewall = CreateObject("HNetCfg.FwPolicy2")
rules = firewall.Rules
output="Name,ApplicationName,LocalPorts,Enabled,Direction":@LF
;for Direction Inbound=1 Outbound =2
;for Enabled -1 = True 0=False
ForEach rule in rules 
   If rule.Action == 0 Then output := rule.Name:",":rule.ApplicationName:",":rule.LocalPorts:",":rule.Enabled:",":rule.Direction:@LF
   ;or display all rules
   ;output := rule.Name:",":rule.ApplicationName:",":rule.LocalPorts:",":rule.Enabled:",":rule.Direction:@LF
Next
Message("Firewall Rules",output)
rules=0
firewall = 0
Exit
;===============================================================================================