以下是用来解决此问题的vbs script脚本代码,它通过快速添加DNS 150.203.x.xx,达到实现解析的目的。其实在TCP/IP属性里也可以手动添加,但过程麻烦,直接运行脚本自动添加减少了手动添加造成的不便。
On Error Resume Next
strComputer = "."
strNewDNSServer = "150.203.x.xx"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
intNewArraySize = 0
arrDNSServerSearchOrder = objNicConfig.DNSServerSearchOrder
If Not IsNull(arrDNSServerSearchOrder) Then
For Each strDNSServer In arrDNSServerSearchOrder
Next
End If
intNewArraySize = UBound(arrDNSServerSearchOrder) + 1
ReDim Preserve arrDNSServerSearchOrder(intNewArraySize)
arrDNSServerSearchOrder(intNewArraySize) = strNewDNSServer
intSetDNS = _
objNicConfig.SetDNSServerSearchOrder(arrDNSServerSearchOrder)
If intSetDNS = 0 Then
Else
End If
Next
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
If Not IsNull(objNicConfig.DNSServerSearchOrder) Then
For Each strDNSServer In objNicConfig.DNSServerSearchOrder
Next
End If
Next
No comments:
Post a Comment