Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Block syntax:
- Dim staticArray()
- ' Prompt user for IP range
- ' Run IP against GetObject below
- ' Input data into array
- Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
- Set colNetAdapters = objWMIService.ExecQuery _
- ("Select * from Win32_NetworkAdapterConfiguration Where DHCPEnabled=False")
- For Each item In colNetAdapters
- staticIP = item.staticIP(0)
- Exit For
- Next
- If staticIP = Then
- Call changeDNS()
- Else
- ' Add 1 to IP Then start from beginning
- End IF
- Sub changeDNS()
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colNetCards = objWMIService.ExecQuery _
- ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled =
- True")
- For Each objNetCard in colNetCards
- arrDNSServers = Array("10.100.70.11", "10.100.70.12")
- objNetCard.SetDNSServerSearchOrder(arrDNSServers)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement