The following VB Script code utilizes WMI to modify the Gateway, DNS settings of this unit (copy the following code. Double-click to run directly).
Const str_newdns1 = "192.168.0.1" const str_newDns2 = "192.168.0.43" const str_gateway = "192.168.0.1"
Set fs = createObject ("scripting.filesystemObject") set outfile = fs.createtextfile ("NetWorkadapterConfiguration.txt", true)
Strwinmgmt = "Winmgmts: {ImpersonationLevel = Impersonate}" set objnics = getObject (strwinmgmt) .instancesof ("Win32_NetworkAdapterConfiguration)
Outfile.writeline ("Begin to Change DNS ...")
For Each objNIC In objNICs If objNIC.IPEnabled Then objNIC.SetDNSServerSearchOrder Array (STR_NEWDNS1, STR_NEWDNS2) outFile.WriteLine (objNIC.Description & "") outFile.WriteLine ( "Change DNS ok") objNIC.SetGateways Array (STR_GATEWAY) outFile.WriteLine ("Change Gateway OK") end ifnextoutfile.writeline ("Change over")