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" 192.168.1.100 all
netsh int ip add address "local area connection" 192.168.1.100 255.255.255.0
netsh int ip delete address "local area connection" 10.168.1.10 all
netsh int ip add address "local area connection" 10.168.1.10 255.255.255.0
netsh int ip add address "local area connection" gateway=192.168.1.254 gwmetric=1
netsh int ip add address "local area connection" gateway=10.168.1.1 gwmetric=1
netsh int ip set dns "local area connection" static 184.108.40.206
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 192.168.1.100 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.