天天看點

修改DNS、網關的VBS代碼。不需重起即時生效

程式代碼 Const STR_GATEWAY = " 192.168.1.254" Const STR_NEWDNS1 = " 221.6.4.67" Const STR_NEWDNS2 = " 192.168.1.254" 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 修改紅色為您的網關位址。修改藍色為主DNS位址。修改綠色為副DNS位址。

繼續閱讀