We help IT Professionals succeed at work.

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

ITZUG
ITZUG asked
on
Medium Priority
1,432 Views
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?
Comment
Watch Question

Commented:
Hi

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
                  Else
                        objICMPSettings.AllowInboundEchoRequest = FALSE
                  End If

      End If
End IF

Next

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.