Set IP Address using a Batch File

This works certainly with Windows XP. It may work with vista or windows 7 but i have not tested. With Windows XP it can sometimes hang. If it does just close the windows and re-run. There is no reason why it hangs and no error in the code. To create a Batch file. Copy the text below into notepad and save the file as a *.bat rather than *.txt

Where items have <> you need to enter the details in there to make it work.

The Code

set varip=<IP ADDRESS>
set varsm=<SUBNET MASK>
set vargw=<GATE WAY IP>
set vardns1=<DNS IP 1>
set vardns2=<DNS IP 2>

netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%

netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1

netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

netsh int ip add dns name = "Local Area Connection" addr = %vardns2%

 

Reset IP address back to DHCP assigned using a batch file

Copy the text below into notepad and save the file as a *.bat rather than *.txt

The Code

netsh int ip set address name = "Local Area Connection" source = dhcp
netsh int ip set dns name = "Local Area Connection" source = dhcp




Disclaimer: By using any of the software mentioned in this document you are adhering to their terms and conditions of use. I do not accept any responsibility for any loss, damage or disruption to your data or computer system that may occur while using the software mentioned in this document.
Site Map | Privacy Policy | Contact Us
| Best viewed in 1024 * 768 or above | ©2008 www.MyPcHealth.co.uk