"Repair" network connections programmatically/from command line
Seems there's a few more things it does:
- Dynamic Host Configuration Protocol (DHCP) lease is renewed: ipconfig /renew
- Address Resolution Protocol (ARP) cache is flushed: arp -d
- Reload of the NetBIOS name cache: nbtstat -R
- NetBIOS name update is sent: nbtstat -RR
- Domain Name System (DNS) cache is flushed: ipconfig /flushdns
- DNS name registration: ipconfig /registerdns
One thing though, if you have a connection that breaks so often you need to programmatically repair your network, this might not be the solution you are looking for.
Thanks, guys, I think I figured it out. The steps in the MS KB article posted by lpfavreau are almost complete. That's what I tried and it didn't work. However, if I do ipconfig /release
first then it seems to work. I suspect that the "Repair" button does that without it being explicitly documented. For my particular case I also had to clear the routes ("route -f"). So, the commands I ended up running in the end are:
route -f
ipconfig /release
ipconfig /renew
arp -d *
nbtstat -R
nbtstat -RR
ipconfig /flushdns
ipconfig /registerdns
I also found some C code to call the actual "Repair Connections" functionality, though I haven't tested it - see last post here.
There is a command to do it from the command line.
Quoting http://en.kioskea.net/faq/sujet-848-windows-xp-repairing-the-network-connection-using-command-line:
Under Windows XP there is a small feature allowing you to repair a network connection. Go to the Network Connections options in Control panel (Control Panel / Network Connections), right click on the network connection you want and choose the repair option.
It is possible to run the same command by using the Netsh utility, within the following command line:
netsh int ip reset c:\network-connection.log
c:\network-connection.log represents the address of the file in which the reporting will be stored
The netsh int ip ...command allows you to reset the TCP/IP.
With Windows XP Service Pack 2, you can use:
netsh winsock reset catalog
Resetting the socket which manages the TCP/IP. This can be used to handle network problems (browser problem, IP address related problems, etc ...)