[ot] Changing network settings with NETSH

Not really about .NET, but I use this for work... :-)

I have to drop my notebook and tablet into several different networks during the week.  It's a pain that I have to reconfigure network and proxy settings everytime I do this.  (Particuarly, one client of mine doesn't use DHCP, otherwise this would be a bit of a non issue.)

The NETSH command can be used from batch files to change network settings.  Here's how to change an interface to use DHCP:

netsh interface ip set address "Local Area Connection 2" dhcp
netsh interface ip set dns "Local Area Connection 2" dhcp

And here's how to switch it to a fixed IP...

netsh interface ip set address "Local Area Connection 2" static 192.168.144.59 255.255.255.0 192.168.144.4 1
netsh interface ip set dns "Local Area Connection 2" static 192.168.144.2

Here's a .reg file for setting the proxy:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="192.168.144.10:8080"
"ProxyOverride"="<local>"

...and for clearing the proxy

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000000

Now, if only SharpReader would pick up the proxy settings from IE automatically.  ;-)

No Comments