一個(gè)可以用來(lái)修改系統(tǒng)的網(wǎng)關(guān)和dns地址的腳本。
代碼如下:
Const T_GATEWAY = "1.1.1.1" '網(wǎng)關(guān)
Const T_NEWDNS1 = "2.2.2.2" 'DNS1
Const T_NEWDNS2 = "3.3.3.3" 'DNS2
strWinMgmt="winmgmts:{impersonationLevel=impersonate}"
Set NICS = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For Each NIC In NICS
If NIC.IPEnabled Then
NIC.SetDNSServerSearchOrder Array(T_NEWDNS1,T_NEWDNS2)
NIC.SetGateways Array(T_GATEWAY)
End If
Next
無(wú)須重新啟動(dòng),不管系統(tǒng)語(yǔ)言