Wednesday, December 16, 2009

Change IE Proxy Setting by VBS

Save the following code in a text file and "Save As" in '.vbs' extension. Then double click on the .vbs file to change proxy:

'***Code Starts Here+++
Option Explicit
On Error Resume Next
Dim objShell
Dim regProxyServerLoc
Dim ProxyServerName

regProxyServerLoc = "HKEY_CURRENT_USER\Software\Microsoft\" & _
    "Windows\CurrentVersion\Internet Settings\ProxyServer"

Set objShell = CreateObject("WScript.Shell")

ProxyServerName = objShell.RegRead(regProxyServerLoc)

If ProxyServerName = "proxy1.com:8080" Then

   objShell.RegWrite regProxyServerLoc,"proxy2.com:8080"

   WScript.Echo "BT Proxy Enabled"

ElseIf ProxyServerName = "proxy2.com:8080" Then

   objShell.RegWrite regProxyServerLoc,"proxy1.com:8080"

   WScript.Echo "TechM Proxy Enabled"

End If

'***Code Ends Here---

No comments:

Post a Comment