How To: IP Configuration Script (win XP)


If you travel a lot with your laptop, and need to switch between
different IP's in different locations, this script is for you.

There are many programs that handle this task very well,
but they cost sometimes pretty big money. This tutorial will show you how to
make your own IP Configuration Script for free.

This script is for a static ip address configuration and
is based on a little program called "NETSH.EXE" which is supplied with Windows.

How it works.


QUOTE

Microsoft Windows XP - Using Netsh

Netsh.exe is a command-line scripting utility that allows you to,
either locally or remotely, display or modify the network configuration of a computer
that is currently running. Netsh.exe also provides a scripting
feature that allows you to run a group of commands in batch mode
against a specified computer. Netsh.exe can also save a configuration
script in a text file for archival purposes or to help you configure other servers.


OK. Let's get down to the business.

First of all, will need to create a batch (.bat) file and a text file (.txt)
I will explain the contens of the text file later on.

1. In our batch file, wee will put the code as follows.

CODE

@echo off
netsh.exe exec textfile.txt
if not errorlevel 1 goto allok
echo.
echo           ERROR !!!
echo.
pause
goto end

:allok
echo.
echo NETSH exec .......... OK!
echo.
:end


In the second line of our batch file wee execute NETSH.exe with a command-line parameter.
The command-line parameter is the path and name of our text file
(or just the name if both files will bee stored in the same directory)

In the next lines of the batch file is a simple error handler.


2. In our text file, wee will put the code as follows.

CODE

interface ip
set address name="Wireless" source=static addr=10.3.123.123 mask=255.255.0.0
set address name="Wireless" gateway=10.1.0.0 gwmetric=0
set dns name="Wireless" source=static addr=88.77.77.3
add dns name="Wireless" addr=163.29.251.110
add dns name="Wireless" addr=194.244.159.1
add dns name="Wireless" addr=195.130.20.131
set wins name="Wireless" source=static addr=none


The "interface ip" command branches to a submenu in the NETSH.exe program.
The "set address name" command configures the IP, the sub-net mask and the default gateway address.
The name "Wireless" is an example interface name, change it to the interface name you want to configure.
In the fourth and lower lines, the "addr" values are the IP addresses of your DNS servers.
In the last line, the "addr" value is the WINS server IP address.

NOTE: Remember to save the text file under the same name you have specifiedin the batch file,
and to save the batch file with the .BAT extention.


This is my first tutorial and i hope
it will be useful for someone.

 

 

 


Reply