Tuesday 20 September 2011

Automate IE proxy setting via VB script

Sometimes when you are connected to vpn client and want to change the proxy settings , it can be done by opening IE --> Tools --> Internet Options --> Connection --> LanSettings and then enter the proxy setting.

We can automate these setting by below script. Just save the below code as .vbs extension , replace the MyProxy with your proxy server IP. Save it & double click on the file. Click Yes to enable & No to Disable the proxy. You are done !!!!!


dim oShell
set oShell = Wscript.CreateObject("Wscript.Shell")


if msgbox("Click Yes to 'Enable'| No to 'Disable'", vbQuestion or vbYesNo) = vbYes then
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "MyProxy", "REG_SZ"
msgbox("Proxy is enabled")
else
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
msgbox("Proxy is disabled")
end if


Set oShell = Nothing