Firewall Status - Ron Crumbaker Web Remote Console 3.21

George K (MeenEnta) shared his code for some of his Ron Console edits in this threadRickyM & I are hoping to share some of them here.

This one is for checking interactively the Firewall Status on the computer.  George's original was a normal button on Ron's console.  But I've changed it to an icon-type -- mainly because I wanted to see how to do it. 

Is this attached file, are the snippets & the .png icon you could use.  Place the Firewall-32x32.png image file in your \Images folder; the folder is located where machrest.asp resides.

Edit machrest.asp, and put this snippet near the top (it was around line 70 for me, but I've edited my machrest quite a bit, might not be the same line number.   It's above the "First Specifiy a machine name".

<!-- Icons Section -->
<td vAlign="top" width="416" height="30" colspan="3">
<IMG title="Firewall Status" style="CURSOR: hand" onclick="FirewallStatus()"
 height="24" src="images/Firewall-32x32.png" width="24" border="0">
</td>
<!-- End of Icons Section -->

--------------------------------

Put this snippet near the bottem by all the other sub/end sub routines:

Sub FirewallStatus
On Error Resume Next
Const Hkey_Local_Machine = &H80000002
strComputer = Trim(document.frmMain.txtValue.value)
If strComputer = "" Then
 MsgBox "Computer Name or IP required",,"Firewall Status"
 Else
  Err.Clear
  Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
  If Err.number <> 0 Then
   MsgBox "Unable to access WMI on " & strComputer & vbCr &_
        "Error: " & Err.description,,"Firewall Status"
   Else
    strKeyPath = "System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile"
    ValueName = "EnableFirewall"
    objReg.GetDWordValue Hkey_Local_Machine, strKeyPath, ValueName, dwValue
    If dwValue = 0 Then
    MsgBox strComputer & " reports Firewall Is " & vbCr &vbTab & "Off",,"Firewall Status"
    ElseIf dwValue = 1 Then
    MsgBox strComputer & " reports Firewall Is " &vbCr & vbtab & "On",,"Firewall Status"
    End If
   End If
End If
End Sub

-----------------------

Both of these snippets are also in the attached file in case word-wrap modifies the lines.

Save machrest.asp.  Mine ended up looking a bit like this:

RonCFWIcon

Published Saturday, January 10, 2009 10:36 AM by skissinger

Comments

No Comments