Stupid Developer Tricks : Proxy Settings

Published On: Dec 10, 2010

Not too long ago I found myself working on multiple projects that had me switching back and forth between multiple different proxy settings based on the fact that I was working from either of the locations or working from the hotel room. They get to the point where setting all of the proxy settings every time I needed to open one of my browser’s was starting to drive me slightly batty. So I did what all of developers do I looked into what it would take to automate the process of setting my proxy settings, and I came up with this little script that I thought I would share:

Write-Host "Proxy Configuration Script"
Write-Host "  Select your proxy settings: "
Write-Host "   "
Write-Host " 1.> Proxy Off  "
Write-Host " 2.> Work  "
Write-Host " 3.> Hotel     "
Write-Host "   "
$selection = Read-Host "Selection"

if ($selection -eq "1")
{
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -value 0
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name AutoConfigURL -value ""
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -value ""
}

if ($selection -eq "2")
{
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -value 0
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name AutoConfigURL -value "http://"
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -value ""
}

if ($selection -eq "3")
{
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -value 1
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name AutoConfigURL -value ""
	set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -value ""
}

Comments