Bettylou

need advice which firewall file to use

2 posts in this topic


Which file is the best file to use?

I have 2 firewall files that are part of a bigger program. There are 2 "IF" commands that are the difference between the two files. Both files give the correct output.

If $OFWall = False Then
If $FW <> 0 Then

Local $OFWall
If @OSVersion = "WIN_XP" Then
$oWMI = ObjGet("winmgmts:\\localhost\root\SecurityCenter")
Else
$oWMI = ObjGet("winmgmts:\\localhost\root\SecurityCenter2")
EndIf
$colItems = $oWMI.ExecQuery("Select * from FirewallProduct")
For $objFirewallProduct In $colItems
$OFWall = $objFirewallProduct.DisplayName
Next
If $OFWall = False Then
    _WinFirewall()
ElseIf $OFWall = "Privatefirewall" Then
FileWrite($File, "Private Firewall" & @CRLF)
ElseIf $OFWall = "COMODO Firewall" Then
FileWrite($File, "Comodo Firewall" & @CRLF)
ElseIf $OFWall = "ZoneAlarm Free Firewall Firewall" Then
FileWrite($File, "ZoneAlarm Free Firewall" & @CRLF)
Else
FileWrite($File, $OFWall & @CRLF)
EndIf

Func _WinFirewall()
    Local $FW = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile", "EnableFirewall")
If $FW <> 0 Then
FileWrite($File,  "Windows Firewall Enabled!" & @CRLF)
Else
FileWrite($File,  "Windows Firewall *Disabled*" & @CRLF)
EndIf
EndFunc
Local $FW = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile", "EnableFirewall")
If $FW <> 0 Then
$FW = "Enabled!"
Else
$FW = "*Disabled*"
EndIf
Local $OFWall
If @OSVersion = "WIN_XP" Then
$oWMI = ObjGet("winmgmts:\\localhost\root\SecurityCenter")
Else
$oWMI = ObjGet("winmgmts:\\localhost\root\SecurityCenter2")
EndIf
$colItems = $oWMI.ExecQuery("Select * from FirewallProduct")
For $objFirewallProduct In $colItems
$OFWall = $objFirewallProduct.DisplayName
Next
If $OFWall = False Then
FileWrite($hLogFile, "Windows Firewall is " & $FW & @CRLF)
ElseIf $OFWall = "Privatefirewall" Then
FileWrite($hLogFile, "Private Firewall" & @CRLF)
ElseIf $OFWall = "COMODO Firewall" Then
FileWrite($hLogFile, "Comodo Firewall" & @CRLF)
ElseIf $OFWall = "ZoneAlarm Free Firewall Firewall" Then
FileWrite($hLogFile, "ZoneAlarm Free Firewall" & @CRLF)
Else
FileWrite($hLogFile, $OFWall & @CRLF)
EndIf

 

Share this post


Link to post
Share on other sites



Which do you prefer?  They look functionally the same.  Well, I mean perhaps. You see,, the first example has a function, so perhaps it is the more functional of the two?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now