Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Block syntax:
  2.  
  3. Dim staticArray()
  4.    
  5. ' Prompt user for IP range
  6.  
  7. ' Run IP against GetObject below
  8. ' Input data into array
  9. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  10. Set colNetAdapters = objWMIService.ExecQuery _
  11. ("Select * from Win32_NetworkAdapterConfiguration Where DHCPEnabled=False")
  12.  
  13. For Each item In colNetAdapters
  14.  staticIP = item.staticIP(0)
  15. Exit For
  16. Next
  17.  
  18. If staticIP =  Then
  19.     Call changeDNS()
  20. Else
  21. ' Add 1 to IP Then start from beginning
  22.  End IF
  23.  
  24. Sub changeDNS()
  25.   strComputer = "."  
  26.   Set objWMIService = GetObject("winmgmts:" _  
  27.   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")  
  28.   Set colNetCards = objWMIService.ExecQuery _  
  29.   ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled =  
  30.  True")  
  31.   For Each objNetCard in colNetCards  
  32.   arrDNSServers = Array("10.100.70.11", "10.100.70.12")  
  33.   objNetCard.SetDNSServerSearchOrder(arrDNSServers)  
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement