By Kardi Teknomo, PhD .

Networking

< Previous | Next | Contents >

NETSH Scripts

Using command line, you need to type the commands every time. Fortunately, you can also put those NETSH commands into a DOS script. A DOS script is a text file where you type all the commands. To make the text file into an executable script, name it with anything with extension of .BAT (for example you can name it Home_LAN.BAT or Office_LAN.BAT). To ease the usage of your script, save that script on your desktop. To run the DOS Script, simply double click the file icon from your desktop.

Here is my DOS script to connect to broadband at home. Just copy and paste into a text file. Save it as Broadband.BAT in your desktop. Just double click the file to run it.

@echo off

rem set into dhcp

netsh interface ip set address name="Local Area Connection" dhcp

netsh interface ip set dns name="Local Area Connection" dhcp

netsh interface ip set wins name="Local Area Connection" dhcp

@echo on

rem show current configuration

netsh interface ip show config

pause

Below is my DOS script to connect to manually assigned IP setting in the office. Just copy and paste into a text file. Save it as OFFICE.BAT in your desktop. Just double click the file to run it. (You need to change the IP address, subnet mask, gateway, DNS and WINS address from the example below)

@echo off

rem set into manual setting of ip address followed by subnet mask and default gateway and end with 1

netsh interface ip set address name="Local Area Connection" static 100.2.10.132 255.255.0.0 100.2.254.254 1

rem set dns and wins address into static

netsh interface ip set dns name="Local Area Connection" static 100.0.1.1

netsh interface ip set wins name="Local Area Connection" static 100.0.1.1

@echo on

rem show current configuration

netsh interface ip show config

pause

Using the two DOS scripts above, now you can switch between two LAN connections easily (just by double clicks the correct script file from your desktop) without typing all the TCP/ IP settings.

Happy networking!

< Previous | Next | Contents >

Rate this tutorial or give your comments about this tutorial

This tutorial is copyrighted .