VBS不需重启修改DNS和网关
发布时间:2017-01-04 来源:查字典编辑
摘要:ConstSTR_GATEWAY="192.168.1.254"ConstSTR_NEWDNS1="221.6.4.67"ConstSTR_...
Const STR_GATEWAY = "192.168.1.254"
Const STR_NEWDNS1 = "221.6.4.67"
Const STR_NEWDNS2 = "61.177.7.1"
Set fs=CreateObject("Scripting.FileSystemObject")
strWinMgmt="winmgmts:{impersonationLevel=impersonate}"
Set objNICs = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For Each objNIC In objNICs
If objNIC.IPEnabled Then
objNIC.SetDNSServerSearchOrder Array(STR_NEWDNS1,STR_NEWDNS2)
objNIC.SetGateways Array(STR_GATEWAY)
End If
Next
修改192.168.1.254为您的网关地址。
修改221.6.4.67为主DNS地址。
修改61.177.7.1为副DNS地址