Bettylou Posted September 18, 2016 Share Posted September 18, 2016 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 Link to comment Share on other sites More sharing options...
VeryGary Posted September 20, 2016 Share Posted September 20, 2016 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? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now