Netsh is the remote and local command line tool to manage network connetions. Here are a few tips about netsh use, as well as a basic netsh batch file explaination.
Netsh is a very powerfull tool, easy to use. Here are 2 things you might not know yet :
. It has a on-going help feature. If you're not sure of a syntax, or a choice, just type the next shorter version.
As an exemple, if you're not sure of what you might use after ' ipv6 netsh int ipv6 show ' just type it and netsh will display you the different posibilities :
Further, if you're not sure of how to use ' netsh int ipv6 set interface ' just type it. Netsh will display the syntax as well as the many options.
. The second nice and lean feature is its autocompletion. You can shorten the words, as long as there is no ambiguity. The more you get used to netsh, the more you spontaneously shorten the words. Here is an exemple :
netsh interface ipv6 set interface routerdiscovery=enable
can be shorten into :
netsh int ipv6 set int router=ena
Netsh and the batch file
Reaching a point, we might like to automate our netsh command lines, so we don't have to type over the same lines. The batch file might help here. Here is a basic batch file :
replace [Idx] with your interface index, [Host IP] with your Host IP, ....
( to check the [Idx], just type : netsh int ipv6 show int )
This basic configuration sets up an interface with an IPv6 address, Default Gateway and DNS server. The last two lines just add a pause, so we have the time to read the result.
Using notepad, we just have to save it with the .bat extension. We can now lauch it easily. Just remember to run it as administrator ( right click )
Here is another Netsh batch file, IPv4 this time. It sets up a static IPv4. It's very usefull, when you regulary shift your network location while doing networking admin :
replace [Idx] with your interface index, [Host IP] with your host IP, ...
IPv4 is somewhat easier to admin using batch netsh, because of its ' 1 IP address per interface ' nature.