Whenever I am working for a company installing there new Domain i get asked for a way to script the proxy Changes. this is so that the people using laptops can take them home and not have to go in to IE and disable proxy.
I have finally got round to writing a small VBS script to achieve this. This script is for to offices but can Easley be used for one office.
I have tryed this on Windows XP and Windows 7
'=================================================================================== ' ' FILE: Proxy_settings.vbs ' ' OPTIONS: No Options, used as a library ' REQUIREMENTS: vbs ver 5.0 or greater ' BUGS: ' NOTES: ' AUTHOR: Ketan Desai ' COPYRIGHT: KETAN DESAI ' VERSION: 1.0 ' CREATED: 06.08.2013 '=================================================================================== Option Explicit Dim WSHShell, strSetting, Gateway1, Gateway2, strQuery, objWMIService, colItems, objItem, strGW, strIP Set WSHShell = WScript.CreateObject("WScript.Shell") 'Define Gateway Addresses Gateway1 = "172.31.0.6" Gateway2 = "192.168.102.6" 'Query the Network Adapter Configuration Class and filter by Network Adapters using DHCP strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE DHCPEnabled=1" Set objWMIService = GetObject( "winmgmts://./root/CIMV2" ) Set colItems = objWMIService.ExecQuery( strQuery, "WQL", 48 ) For Each objItem In colItems If IsArray( objItem.DefaultIPGateway ) Then If UBound( objItem.DefaultIPGateway ) = 0 Then strGW = objItem.DefaultIPGateway(0) strIP = objItem.IPAddress(0) 'MsgBox strIP & chr(13) & strGW Else End If End If Next 'if you are in The office you will have the proxy Enabled If strGW = Gateway1 then WSHShell.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD" 'MsgBox "Your are in Office One " & chr(13) & "Gateway: " & strGW else 'if you are in The second office you will have the proxy Enabled If strGW = Gateway2 then WSHShell.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD" 'MsgBox "Your are in Office Two" & chr(13) & "Gateway: " & strGW else 'if you are Not in The office you will have the proxy Disabled WSHShell.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD" 'MsgBox "Your are not in Office " & chr(13) & "Gateway: " & strGW End IF End IF
I hope you find this helpful