Categorías
Visual Basic

Script de cambio de dns

Este verificará si ya tiene las DNS nuevas, en caso contrario, las cambiará.

On Error Resume Next
strComputer = "." 
strDNSNuevas = "Servidor_DNS_1,Servidor_DNS_2″ 
Set objWMIService = GetObject("winmgmts://" _ & "{impersonationlevel=impersonate}|\" & strComputer & "rootcimv2″) 
Set colNetCards = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IpEnabled = True") 
For Each objNetCard In colNetCards
    strDNSs = Join(objNetCard..DNSServerSearchOrder,",") 
    If strDNSs <> strDNSNuevas Then
        objNetCard.Set.DNSServerSearchOrder(Join(strDNSNuevas,","))
    End If 
Next