Very often, when working on a remote site, you must distort the network cable or disconnect and enable the network adapter. But since we cannot do this physically, we have to ask someone to do it or to excel in such ways. In Linux, this happens easily, via ssh we drive in ifdown eth0 & ifup eth0 and all the rules. In Windows, you have to do the following to restart the network adapter
1. Create bat-file to restart the network adapter:
- Create a bat-file, enter the following script there necessarily in ANSI encoding:
netsh interface set interface name = "Local Area Connection" admin = DISABLED
ping 127.0.0.1 -n 6> nul
netsh interface set interface name = "Local Area Connection" admin = ENABLED
and run as administrator.
where “Local Area Connection” is the name of the network adapter in your Windows. It may be called “Local Area Connection 2” or “Local Area Connection 3”. For convenience, I renamed the connections to LAN, WiFi, Internet, Router or Bluetooth.
Remarks: works not only in Windows 7, but also in Windows 8 and Windows 10.
Also consider using Action1 to restart the network adapter if:
- You need to perform this action on multiple (hundreds or even thousands) computers simultaneously.
- Some of your endpoints are laptops not connected to corporate network at all times.
Action1 is a cloud-based platform for software deployment, software/hardware inventory, patch management, endpoint configuration and more. It is free with basic functionality.