[Modified] Double Click to Switch Wireless And LAN

2013-09-17

Situation:
Since I'd created the program for my clients.(Link here) Recently they told me they couldn't swap successfully bewteen WAN and LAN.



Then I checked the program and found nothing wrong with it. I dig more and they said they inserted the another one yesterday. Finally I realized what's going on my program.

If you've inserted more than one Wireless Adapter before, the "Registry" will exist its record and the next "Wireless Adapter" will add the second record "Wireless Network Connection 1,2,3..."

But how can i know which Connection they are using, is Connection 1 or 2 or 3?


Solution:
  • First you need to find where your Connection Registry at
  • Go to Registry
HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\xxxx\Connection

  • Find 3 values
DefaultNameIndex, PnpInstanceID, and MediaSubType

  • Go to Registry
HKLM\SYSTEM\ControlSet001\services\xxxx\Enum

  • Find 2 values and  use one value to compare with "DefaultNameIndex" in HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\xxxx\Connection

They will be looked like different when you plug in and out

When Plugging in, it will look like


[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\"xxxxyourWirelessDriverName"\Enum]
"Count"=dword:00000001
"NextInstance"=dword:00000001
"0"="USB\\VID_0BDA&PID_8172\\00e04c000001"


When Plugging out, it will look like


[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\"xxxxyourWirelessDriverName"\Enum]
"Count"=dword:00000000
"NextInstance"=dword:00000000


#Notice the value  "0"="USB\\VID_0BDA&PID_8172\\00e04c000001"
It's the value as the same as  "DefaultNameIndex"

Now you can use this skill to modify your VBScript program..

Design concept:




LAN
WIRELESS

LAN
WIRELESS

LAN
WIRELESS
IF
ON
OFF
DO
OFF
ON
SO

ON
IF
OFF
ON
DO
ON
OFF
SO
ON

IF
OFF
OFF
DO
ON
OFF
SO
ON

IF
ON
ON
DO
OFF->ON
OFF
SO
ON

 




Code Ref website:



Usage:
save as *.vbs, and double click
or compile *.vbs to be a *.exe


Newer Older