Author Topic: HNetCfg.FwPolicy2 firewall quickie  (Read 139 times)

stanl

  • Pundit
  • *****
  • Posts: 1422
HNetCfg.FwPolicy2 firewall quickie
« on: September 09, 2020, 12:30:13 pm »
Code: Winbatch

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