Punk-coder Blog

Stupid Developer Tricks : Proxy Settings

by on Dec.10, 2010, under Technology

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://<YourCompaniesAutoConfig>"
	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 "<Your Companies HardCodedServer:port>"
}

1 Comment for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...