How to change network adapter settings in Windows 7 from command line
February 15th, 2010 by Black
I have two internet connections at home, mainly because I’m an Internet addict and any minute without Internet generates lots of frustration and secondly because I cannot afford to have any problems while connecting to the office network.
Now, one of my providers had some problems lately and I guess that’s just because of the rough winter which does not seem to end. I am using this provider as the main link on the desktop computer, directly plugged in, the other one being used for the wireless network (iPhone, notebook, fridge etc). Since the connection is getting bad from time to time, I need to switch from one network adapter to another that has just lan connectivity but it is connected to the wireless router. This means I just need to add the router IP address as the gateway and DNS on the secondary adapter. Doing this with clicks on the adapter settings takes time and when you have to train other people that use the same computer to do this it gets rough.
So I made this two batch scripts that add or remove the DNS/gateway IPs from the secondary adapter, so whenever I need to switch from one adapter to another I click on the corresponding bat files.
To get Internet connectivity on the secondary adapter:
netsh interface ip set address name=”your_network_adapter_name” source=static addr=10.0.0.xxx mask=255.255.255.yyy gateway=10.0.0.zzz
netsh int ipv4 set dnsservers “your_network_adapter_name” static 10.0.0.zzz primary(where 10.0.0.zzz is the wireless router IP address)
To remove Internet connectivity on the secondary adapter:
netsh interface ip set address name=”your_network_adapter_name” source=static addr=10.0.0.xxx mask=255.255.255.yyy
netsh int ipv4 delete dnsservers “your_network_adapter_name” 10.0.0.zzz
These two scripts must be run with elevated privileges in Windows 7 (right click on the script -> Run as Administrator). As this might not be the most elegant way to switch the Internet connection and might need improvement to completely disable the first adapter, it works for me as it is.
| Digg it | +Google | Reddit | Y! MyWeb