views:

3927

answers:

4

OS: Vista enterprise

When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option.

This takes a lot of time (3-4 min) and so i was trying to find either a command or a powershell script/cmdlet which i can use directly to reset the network adapter and save myself these 5 mins every time i have to switch between the networks. Any pointers?

+3  A: 

See this article from The Scripting Guys, "How Can I Enable or Disable My Network Adapter?"

Mike L
+2  A: 

You can also try this in a .BAT or .CMD file:

ipconfig /release
ipconfig /renew
arp -d *
nbtstat -R
nbtstat -RR
ipconfig /flushdns
ipconfig /registerdns

These commands should do the same things as the 'Diagnose and Repair' for the network adapter, but is WAY faster!

Let me know if this helps! JFV

JFV
Or in a .ps1 file, since they are all simple .exe's :)
Emperor XLII
Hi JFV... thanks for your help! The commands mentioned by you did not 'reset the network adaptor'. However, they do seem to do same as the 'Get new IP settings automatically' option of diagnose and repair.
Mohit
+6  A: 

You can use WMI from within PowerShell to accomplish this. Assuming there is a network adapter who's device name has Wireless in it, the series of commands might look something like the following:

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
$adaptor.Enable()

Remember, if you're running this with Window's Vista, you may need to run the PowerShell as Administrator.

Scott Saad
A: 

You can also use the Microsoft utility devcon.exe.

First, run devcon listclass net to find your Device ID.

Then use this device ID in this command: devcon restart PCI\VEN_16* (using the '*' wildcard to avoid needing to enter the entire ID string).

Andrew Strong