How can I connect by wireless without unplugging the cable?
This is relatively easy using two batch files to connect to preferred network adapter, disconnecting the other.
First, enter following command in Command Prompt to find out Index values for both wired and wireless network adapters (#1 in next screenshot):
wmic nic get name, index
In this example case, wired NIC is 2, and wireless 4 (#2 & #3 in screenshot).
Now enter following command to find out wireless network profile name (#4):
netsh wlan show profiles
Note the profile name (#5)
OK, now the two batch files needed.
Batch 1: Disconnect Ethernet (wired) connection and connect to wireless
Copy the following and paste it to new text file in Notepad. Edit NIC Index value according to your actual one, in this sample 2 is wired NIC. Also edit the Network Profile Name to match yours:
Code:
wmic path win32_networkadapter where index=2 call disable
netsh wlan connect YourNetworkProfileName
msg.exe * /time:30 Ethernet disconnected. You are now connected to wireless network
Save the file as WIFI.bat:
When the batch is run, it disables the wired NIC, and connects to your wireless network.
Batch 2: Disconnect wireless connection and connect to wired
Copy the following and paste it to new text file in Notepad. Edit NIC Index values according to your actual ones, in this sample 2 is wired, 4 wireless:
Code:
wmic path win32_networkadapter where index=4 call disable
wmic path win32_networkadapter where index=4 call enable
wmic path win32_networkadapter where index=2 call enable
msg.exe * /time:30 Wi-Fi disconnected. You are now connected to wired network.
Save the file as WIRED.bat
When the batch is run, it disables the wireless NIC, which causes the connection being disconnected. It then enables the wireless NIC again, but does not connect to it (it must be enabled next time you run the WIFI.bat). Finally, the batch enables the wired NIC. No need to connect to it, wired connection will be made automatically when wired NIC is enabled and Ethernet cable connected.
Notice that establishing a wired connection can take a few seconds. Just wait, don't panic when Not Connected icon in notification area is shown until connection is established!
Create elevated shortcuts
Create a shortcut for both batch files (tutorial, see option 4).
Set both shortcuts to be run as administrator by right clicking them and selecting Properties. In Shortcut tab of Properties, click Advanced button, select Run as administrator:
Click OK to save Advanced Properties, click OK to save Properties.
To change icons for your shortcuts, see this tutorial: Change Icon of Shortcut in Windows 10
Copy or move the shortcuts to desktop.
That's it. Now you have shortcuts on your desktop to connect wired or wireless, as you'd prefer:
You will get a note on desktop to show what connection is used:
The messages close automatically in 30 seconds.
Notice that as these shortcuts are run as admin, the UAC prompt will be shown. In case you do want to make shortcuts to be run without UAC prompt, see this tutorial: Create Elevated Shortcut without UAC prompt in Windows 10
Kari