本帖最后由 asura 于 2012-6-12 16:14 编辑 set_DNS("8.8.8.8",'4.4.4.4','10.1.1.1')
Func set_DNS($myDns1,$myDns2,$myDns3)
Dim $colItems
Dim $setdns[3]
$setdns[0]=$myDns1
$setdns[1]=$myDns2
$setdns[2]=$myDns3
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
;;修改DNS信息
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress <> '00:00:00:00:00:00' AND IPEnabled = TRUE", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
$info = ""
For $objNetAdapter In $colItems
If StringRegExp($objNetAdapter.Description, '.*TAP*', 0) = 0 And StringRegExp($objNetAdapter.Description, '.*VMware*', 0) = 0 Then
$objNetAdapter.SetDNSServerSearchOrder ()
$errDNS = $objNetAdapter.SetDNSServerSearchOrder ($setdns)
;MsgBox ("","",$objNetAdapter.Description )
;MsgBox ("","",$errDNS)
If $errDNS = 0 Then
$info = $info & $objNetAdapter.Description & @CRLF
EndIf
EndIf
Next
MsgBox (64,"DNS修改","以下网卡已完成修改:"& @CRLF & $info,5)
EndIf
EndFunc
麻烦大家,因为我检查多次,就是没效果!希望能得到大家的帮忙,谢谢!用的是最新版本,貌似不行,我换了3.7.15.1 可以了,不知道什么情况。 |