Enable\Disable "Allow incoming Echo request" in the windows firewall

Posted on 2009-02-09
Last Modified: 2012-05-06
I would like to enable the "Allow incoming Echo request" when my users are on our corporate network as they will be protected by our newtork. But I would like it disabled when they using ADSL off our network. Is it possible to do this and how?
Question by:ITZUG
    1 Comment
    LVL 8

    Accepted Solution


    Try the following script, open notepad, copy and paste the script below into notepad, save as icmp.vbs, open command prompt and run from the directory you save icmp.vbs the following command
    cscript icmp.vbs

    This script takes the network name which is a variable strConnectionName which you need to change and on the computer that is run, checks to see if that nic is connected
    "objItem.NetConnectionStatus = 2"
    and if so, displays name, mac address and description. It then enable the echo request if its disabled. If its disabled, it enables it.
    The script is commented, well a little bit :) but you should be able to amend it

    The idea is that this script could be part of log on/off script which when run, does the check and enables it if required.

    strConnectionName = "Wireless Network Connection"

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")

    For Each objItem in colItems

    If objItem.NetConnectionStatus = 2 Then      'If connected then...
          If objItem.NetConnectionID = strConnectionName Then      'The connected to the required network then...
                    Wscript.Echo "Name: " & objItem.Name      'Show details
                    Wscript.Echo "Description: " & objItem.Description            'Show details
                    Wscript.Echo "MAC Address: " & objItem.MACAddress            'Show details

                      'Modify firewall
                      Set objFirewall = CreateObject("HNetCfg.FwMgr")
                      Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
                      Set objICMPSettings = objPolicy.ICMPSettings
                      'Enable ICMP Allow incomming echo request if disabled otherwise disable
                      If objICMPSettings.AllowRedirect = FALSE Then
                            objICMPSettings.AllowInboundEchoRequest = TRUE
                            objICMPSettings.AllowInboundEchoRequest = FALSE
                      End If

          End If
    End IF



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
    It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now