;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
;===============================================================================================