1

I have a laptop that when I have it on my desk, it's connected to a usb wifi adapter. However, whenever I bring it anywhere else I use the internal wifi card. But this means I have 2 interfaces, both enabled, and connected. So to make sure when I am using the correct one when I am at my desk, I go into the adapter settings and disable the internal wifi interface. I am looking to create something to speed up the process, as well as learn about command line scripting!

I am trying to create a batch file to do the following:
Note:
WiFi = USB adapter. Always use this if connected.
Wi-Fi 2 = internal wifi interface. Only use if the other is disabled or not connected

1) Check to see which NIC adapter is enabled/connected.
netsh interface show interface
2) Create an IF statement -
- IF WiFi is enabled and connected - disable Wi-Fi 2
- ElseIf WiFi is not enabled - enable Wi-Fi 2

However, I am not sure how to do this in CMD. Any pointers? Is there something else I need?

jarnowicz
  • 175
Labarr
  • 11

1 Answers1

0

Make 2 .bat files. One should enable one adapter and disable the other, the second one the opposite:

A1.bat:
@netsh interface set interface name="LAN1" admin=disabled
@netsh interface set interface name="LAN0" admin=Enabled

A2.bat:
@netsh interface set interface name="LAN0" admin=disabled
@netsh interface set interface name="LAN1" admin=Enabled

Use them when you need to switch.

Overmind
  • 10,308