Renew static IP Address using batch file

On my work I have strange problem inside Local network. Two computers continuously loose connection in between network resources while others doesn’t experiencing this problem. After restarting them all seems to work fine till it happens again. To resolve my problem I have made this *.bat file which should rewrite IP addresses and keep computers in working state without need to restart them.

Command I have use inside this file is called netsh and you can run it through MS cmd. I use my *.bat file on MS Windows XP SP3 Pro and it works fine. On the internet you can find many ways how to use this command, and I was struggling for a while to make my file run without any error messages. If you are looking for something like this make sure you really need this command because this line of codes inside my file are made for my specific case. Keep in mind that you should make necessary adjustments.

This netsh command works on Windows XP SP3 Pro with static IP addresses and case where you have secondary IP addresses provided. Take a look at the picture where you can see that I’m using two different IP addresses.

When computers loose connections my coworkers need to restart and then all works fine. To avoid restarting computers I have spend some time to make this batch file and to test it how it works. Here you can see how I made batch file to rewrite static IP records.

netsh int ip

On the Advanced TCP/IP Settings tab I have list of two IP’s and a list of two Gateways. I want to delete these IP addresses and retype them again. To do that I’ll use testbat.bat file with this code inside.

netsh int ip delete address "local area connection" all
netsh int ip add address "local area connection"

netsh int ip delete address "local area connection" all
netsh int ip add address "local area connection"
netsh int ip add address "local area connection" gateway= gwmetric=1
netsh int ip add address "local area connection" gateway= gwmetric=1

netsh int ip set dns "local area connection" static


Take a closer look at the code and see how it works. This code should be used in case you already have static IP addresses.

command prompt netsh int ip

First line of code is going to delete in Local Area Connection and all record which comes with that IP address.
Second line is going to write new (old) IP addresses again without Gateway and DNS.
Now when we have one static IP record written – code can delete second IP addresses.
Once again – fourth line of code is going to write deleted IP addresses and Subnet Mask without Gateway and DNS.
Fifth and sixth lines of code writing Gateway IP’s in desired order.
On the end – code writes Primary DNS record.

7 thoughts on “Renew static IP Address using batch file

  1. wiggle salomon

    I'm very happy to read this. This is the kind of manual that needs to be given and not the accidental misinformation that is at the other blogs. Appreciate your sharing this best doc.

  2. salomon x ultra gtx opiniones


    salomon x ultra gtx opiniones

    Highly energetic post, I loved that bit. Will there be a part 2?

  3. salomon pro 3d

    Excellent read, I just passed this onto a friend who was doing some research on that. And he just bought me lunch because I found it for him smile Thus let me rephrase that: Thank you for lunch!

  4. salomon speedcross 2


    salomon speedcross 2

    Definitely believe that which you said. Your favorite justification seemed to be on the net the simplest thing to be aware of. I say to you, I certainly get irked while people consider worries that they just do not know about. You managed to hit the na…

  5. louboutin online


    louboutin online

    Itˇs really a cool and useful piece of info. I am happy that you just shared this helpful info with us. Please stay us up to date like this. Thank you for sharing.

  6. Isabel Marant Sneakers Outlet


    Isabel Marant Sneakers Outlet

    hi!,I like your writing very a lot! proportion we keep in touch more approximately your post on AOL? I need a specialist on this area to solve my problem. Maybe that's you! Having a look forward to peer you.

Add Comment