Every day I (and I guess most of us) face an issue regarding the adapter setting change. For office, we have a dedicated IP and settings, so change the settings, then as soon as I go home I need to connect to my home Wi-Fi and that need automatic IP and DNS settings, so again change the settings to default. Previously I was on Ubuntu so I never cared about this as Ubuntu handles this very efficiently. But in Windows go to network settings then adapter settings blah blah blah. So here I will show to create 2 files that is office.bat and default.bat for doing it easily on windows 7. These files changes the settings as soon as you run these files.
:: Configuration Variables :: set connectionName="Wireless Network Connection" set ipAddress=x.x.x.x set subnetMask=x.x.x.x set defaultGateway=x.x.x.x set primaryDNS=x.x.x.x set alternateDNS=x.x.x.x netsh interface ipv4 set address name=%connectionName% source=static addr=%ipAddress% mask=%subnetMask% gateway=%defaultGateway% netsh interface ipv4 set dns %connectionName% static %primaryDNS% netsh interface ipv4 add dns %connectionName% %alternateDNS% index=2
The content in these batch files is self explanatory
connectionName -> The name of the connection you want to modify
:: Configuration Variable :: set connectionName="Wireless Network Connection" netsh interface ip set address %connectionName% dhcp netsh interface ip set dns %connectionName% dhcp
Save this file as default.bat and run as administrator and the setting change to DHCP.
These are applicable for LAN also you just need to give the correct connection name in the connectionName variable.
:: Configuration Variable :: set connectionName="Wireless Network Connection" :: Disable :: netsh interface set interface %connectionName% DISABLED :: Enable :: netsh interface set interface %connectionName% ENABLED