Usuário com melhor resposta
Como Definir IP/DNS somente para "Local Area Connection"?

Pergunta
-
Olá Pessoal, tudo bem ?
utilizo dois scripts para manipular o endereçamento IP, um deles para definir IP fixo e outro para voltar ao IP Dinamico.
minha dúvida é: Como definir IP/DNS apenas para "Local Area Connection" e posteriormente voltar para DHCP utilizando os scripts abaixo?
Definir IP FIXOSet objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("200.175.97.345")
strSubnetMask = Array("255.255.255.248")
strGateway = Array("200.175.97.346")
strGatewayMetric = Array(1)
strDNS = Array("200.176.2.10","200.221.11.98")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
objNetAdapter.SetDNSServerSearchOrder strDNS
NextDefinir IP Dinâmico (Obtendo do DHCP)strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapterserrEnable = objNetAdapter.EnableDHCP()
arrDNSServers = Array()
objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
NextTela Visual com botões para definir IP FIXO / IP Dinamico (Utilizando o AUTOIT)include <GUIConstants.au3>
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("IP which you want to use?", 330, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Choose between the valid IP on the Internet or CDS DHCP mode.", 10, 10)$ipbutton = GUICtrlCreateButton("INTERNET MODE", 20, 40, 120)
GUICtrlSetOnEvent($ipbutton, "ipbutton")$dhcpbutton = GUICtrlCreateButton("DHCP MODE", 190, 40, 120)
GUICtrlSetOnEvent($dhcpbutton, "dhcpbutton")GUISetState(@SW_SHOW)
While 1
Sleep(1000) ; Idle around
WEndFunc ipbutton()
;Note: at this point @GUI_CTRLID would equal $ipbutton,
;and @GUI_WINHANDLE would equal $mainwindow
;MsgBox(0, "GUI Event", "You pressed INTERNET!")
Run('C:\Windows\System32\setip.bat')
$destination = @Systemdir & "\setip.gif"
;SplashImageOn("", $destination,1017,758)
Sleep(7000)
SplashOff()
exit
EndFuncFunc dhcpbutton()
;Note: at this point @GUI_CTRLID would equal $ipbutton,
;and @GUI_WINHANDLE would equal $mainwindow
;MsgBox(0, "GUI Event", "You pressed DHCP!")
Run('C:\Windows\System32\setdhcp.bat')
$destination = @Systemdir & "\setip.gif"
;SplashImageOn("", $destination,1017,758)
Sleep(7000)
SplashOff()
exit
EndFunc
Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;and @GUI_WINHANDLE would equal $mainwindow
;MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
Exit
EndFuncSe alguém souber, agradeço desde já !