0% found this document useful (0 votes)
347 views2 pages

How To Change IP Address Using A Batch File Script On

This document describes how to create a batch file script to change the IP address on Windows computers using the Netsh command line utility. The batch file uses Netsh commands like "netsh interface ip set address" to disable the network interface, release the current IP address, and assign a new static IP address. This allows laptop users who connect to different locations to easily change their IP settings by running the appropriate batch file for each location rather than manually changing network settings.

Uploaded by

kamakom78
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
347 views2 pages

How To Change IP Address Using A Batch File Script On

This document describes how to create a batch file script to change the IP address on Windows computers using the Netsh command line utility. The batch file uses Netsh commands like "netsh interface ip set address" to disable the network interface, release the current IP address, and assign a new static IP address. This allows laptop users who connect to different locations to easily change their IP settings by running the appropriate batch file for each location rather than manually changing network settings.

Uploaded by

kamakom78
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

How to change IP address using a Batch File Script

on Windows?
Posted by: lakkireddymadhu on: August 11, 2014

In: Technology

2 Comments

How to change IP address using a Batch File:


Starting with Windows 2000, Microsoft has provided a powerful utility, Netsh, which lets you display
and modify the network configuration of Windows computers. You can use the Netsh on the command
line or in a batch file. Heres an example of how you can create a batch file that changes the IP
address of the local machine.
Netsh 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 also provides a
scripting feature that allows you to run a group of commands in batch mode against a specified
computer. Netsh can also save a configuration script in a text file for archival purposes or to help you
configure other servers.
In my environment, we dont use DHCP. We use static IP addresses. Using static IP addresses usually
doesnt present any problems because we rarely move desktops between locations. However, the
people who use laptops usually visit multiple locations. At each location, theyve been assigned a
separate IP address. Each time they change location, they look up the appropriate network settings in
a .txt file, then manually change those settings. This occasionally creates problems because they have
to remember the correct steps to change their network settings and sometimes they mistakenly enter
wrong numbers.
I found a solution. For each location, I created a simple batch file that the laptop users can run.
Whenever they want to change their IP settings, all they have to do is execute the appropriate batch
file.
The batch file uses the Netsh utility and contains below given commands.
Copy the code given below in the Notepad and save it with the .bat extension.
Run the .bat file with double click.
In the some cases, the .bat file needs to run with administrators privileges. Right-click on the .bat
file and choose Run as administrator.

@echo off
ipconfig /flushdns
ipconfig /release
netsh interface set interface "Local Area Connection" disable
netsh interface ip set dns "Local Area Connection" static
netsh interface ip set address "Local Area Connection" static
echo Wait 5 seconds...
ping -n 60 -w 1000 0.0.0.1 > nul
netsh interface set interface "Local Area Connection" enable
netsh interface ip set address "Local Area Connection" static 192.168.XXX.XX
255.255.255.0 192.168.XXX.X
netsh interface ip set dns "Local Area Connection" static 192.168.XXX.XXX
To change the IP Address to obtain an IP address automatically or to remove the IP Address,
Copy the code given below in the Notepad and save it with the .bat extension.

@echo off
ipconfig /flushdns
ipconfig /release
netsh interface set interface "Local Area Connection" disable
netsh interface ip set dns "Local Area Connection" dhcp

netsh interface ip set address "Local Area Connection" dhcp


echo Wait 5 seconds...
ping -n 60 -w 1000 0.0.0.1 > nul
netsh interface set interface "Local Area Connection" enable
Now, whenever the users want to change their IP settings, all they have to do is run the batch file.
Note: This entire process (IP Address change process) will take max 60 to 80 seconds.

You might also like