Kyle Jones explains how to use a Windows XP command-line device control mechanism to quickly and conveniently change network settings. To illustrate this interface, he shows how to disable one network device and enable another, all in one step.
Introduction
I run Windows XP Professional on a laptop that has both an Ethernet network card and a Wireless network card. When I am on the Ethernet I don't need the Wireless (especially to save batteries) and when I am on Wireless I don't need Ethernet. Also I work in many different networks and often need to change my network settings, IP, gateway, DNS, etc. Sometimes I can get that information from the network through DHCP and other times I need or want a static IP inside the network.
I looked around for software that could do this for me and I found a few but all of them cost too much money and didn't have the interface I wanted. All I wanted was some icons to click to change the network settings. After a bit of research I found out that there were some command line tools that could help me do the changes I wanted to do. As far as I know this will only work with Windows XP; sorry to the Windows 9x users out there but I don't know what the tools are that would let you achieve the same thing, if you know a way please use our contact form and let us know. For the sake of this how-to, I will assume you have a basic knowledge of networking and Windows. You will also need to be logged in as an Administrator (This is not an issue with Windows XP Home).
Required Software
netsh a Command Line Utility that comes with Windows XP
devcon a Command Line Utility Alternative to Device Manager free from Microsoft be sure to put the executable into some place in your path (e.g. The c:\windows folder)
notepad a Windows text editor that comes with Windows
cmd the Windows Command line prompt
Step one
Create a working directory- From the start menu click on "Run"
- In the box type "cmd" and click the "OK" button.
- When the command prompt box opens up type "mkdir c:\net" and hit Enter
- Then type "cd \net" and hit Enter
- Type "devcon find lan" and hit Enter
- This will list all the PCI cards on your computer. You will need to go through this list and find the id for both your Wireless card and your Ethernet card. The parts you will need will look something like this "PCI\VEN_14E4&DEV_4324" (You don't need anything after the second &) Write down these ids for later reference.
- Leave this window open
Step Two
Creating Network Settings Profiles- In your "Start" menu go to "Settings" and Right-Click on "Network Connections" then hit "Explore"
- Right Click on each of your Wireless and Ethernet connections and make sure they are Enabled
- Then Right Click on your Wireless and Ethernet connections and hit "Properties" Scroll down the list on this dialogue box and click on the one that says "Internet Protocol (TCP/IP)" don't uncheck it, but hit the "Properties" button below it. Now set up that interface the way you want it for one profile. When you are done click "OK" and "OK" again to get back to the Network Connections.
- Now go back to the Command Prompt Window that we left open and type "netsh -c interface dump > c:\net\setup1.txt" and hit Enter.
- Do 3 and 4 for each network you want to set up but with a different file name.
Step Three
Creating the scripts- From the Command Prompt Window type "notepad setup1.bat". When it prompts you to create the file hit "Yes"
- In the file type:
@ECHO OFF REM This disables a device devcon disable "{ID of one network card}" REM This enables a device devcon enable
"{ID of the other card}" REM This loads the network REM settings for both devices netsh -f c:\net\setup1.txt - Next click "File", "Save" and then quit
- Next you could create a setup2.bat that switches which devices are enabled or that loads a different network profile. Do this for as many setups as you want.
Step Four
Creating Short-Cuts to your scripts- From the Command Line prompt type "explorer c:\net" and hit Enter
- For each "MS-DOS Batch File" or .bat file that you created drag it to your Desktop while holding Shift and Ctrl in order to create a short-cut and not just move the file.
- Double Click on the icons and test your setups.
Conclusion
This is not the easiest thing to set up but as you can see it can also be quite powerful and useful. If you have any comments on how we can improve this how-to please use our contact form and let us know!
Good luck!
Disclaimer
Use the information in this document at your own risk. We disavow any potential liability for the contents of this document. Use of the concepts, examples, and/or other content of this document are entirely at your own risk.
All copyrights are owned by their owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark.
Naming of particular products or brands should not be seen as endorsements.
