When you own a laptop and you work in different environments you might know this scenario: you hook up your laptop to a new network and first of all you have to reconfigure your network settings. Best case would be all networks use DHCP to broadcast all necessary settings, but that’s not always the case. And there might be some features that cannot be made available using DHCP like adding special network folders or printers.
Fiddling with your setup each time you change your location, is quite annoying and error-prone. So you might come up with the idea to write a little script to do just the job. But how can you change network-settings from e.g. VBScript? Well, adding network-shares and -printers is no problem, but how to change an network interface from DHCP to a static IP? OK, so you have to use netsh
, there seems to be no other way to manipulate network (interface) settings from within a script. But netsh
is so ugly, because of it’s syntax … Well, one naive way of using netsh
would be to dump the current config to a file. This way you will just have to configure your interfaces once manually and then just restore the dumped configurations. Creating a dump of the current configuration can be done by netsh interface dump >config1.txt
, and a restore can be achieved by netsh exec config1.txt
.
Well, I just discovered a little application called Net Profiles, that could just solve this problem. You can manage different profiles, and you just need to apply the profile. This is quite handy.