Não há recurso embutido para fazer isso, mas você pode conseguir o que deseja com um script AutoIT com alguma ajuda de WMI .
Dê uma olhada neste script que o Neutro do Fórum AutoIT escreveu para identificar a conexão de rede ativa no momento e alterar suas configurações de DNS:
#requireadmin
#include <Array.au3>
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$query = ""
Local $active_netword_cards[1]
Local $network_cards_to_setup[1]
$active_netword_cards[0]=""
$network_cards_to_setup[0]=""
;getting a list of all network cards
$objWMIService = ObjGet("winmgmts:\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
if $objItem.NetConnectionStatus == "2" OR $objItem.NetConnectionStatus == "9" Then ;if the network connection is active, we add the index of the network card and the connection name to $active_netword_cards array
_arrayAdd($active_netword_cards, $objItem.Index)
_arrayAdd($active_netword_cards, $objItem.NetConnectionID)
endif
Next
Endif
;getting settings from all network cards in the array $active_netword_cards
for $i = 1 to UBound($active_netword_cards) - 1 step 2
$query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & $active_netword_cards[$i], "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $query
if $objItem.DHCPEnabled == "False" Then _arrayAdd($network_cards_to_setup, $active_netword_cards[$i+1]) ;if DHCP is disabled, we add the network card name in the $network_cards_to_setup array
next
Next
;setting up primary DNS server of all network cards in the $network_cards_to_setup array
;DNS server used in this example is 10.10.2.45
for $i = 1 to UBound($network_cards_to_setup) - 1 step 1
Runwait('netsh interface IP ADD DNS "'& $network_cards_to_setup[$i] &'" 10.10.2.45 index=1')
Next
Você pode modificar o script para fazer um loop em intervalos pré-determinados e sempre que uma conexão Ethernet for detectada em $active_netword_cards
, você poderá executar este comando do PowerShell de dentro do script AutoIT