Submitted By: David Cornwall

Retrieves a list of network adapters and their IP addresses, then uses those addresses to determine whether or not it should disable proxy settings. I have this set up as a logon script through the local security policy for all my laptops.

Visual Basic
Edit|Remove
on error resume next
const HKEY_LOCAL_MACHINE = &H80000002 
strComputer = "."
strdisable = 1
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then 
        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
'            WScript.Echo IPConfig.IPAddress(i)
		strIP = Left(IPConfig.IPAddress(i), 5)
			Select Case strIP
				case "0.0.0" ' wscript.echo "not connected wireless"
			
				case 10.10 ' wscript.echo "first floor"
					strdisable = 0					
				case 10.20 ' wscript.echo "second floor"
					strdisable = 0					
				case 10.30 ' wscript.echo "third floor"
					strdisable = 0					
				case 10.40 ' wscript.echo "fourth floor"
					strdisable = 0				
				case 10.70 ' wscript.echo "VPN Network"
					strdisable = 0					
				case Else ' wscript.echo "outside corporate network"

			End Select
        Next
    End If
Next
' wscript.echo "disable proxy 1=yes / 0=no / 3=not connected    " & strdisable

If strdisable = 1 then
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &_
     "\root\default:StdRegProv")
	strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
	strValueName1 = "ProxyEnable"
	strValue1 = "00000000"
	oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,strValue1

End if