使用腳本自動修改ip設置 - 中國WEB開發者網絡 (http://www.webasp.net) -- 技術教程 (http://www.webasp.net/article/) --- 使用腳本自動修改ip設置 (http://www.webasp.net/article/16/15339.htm) |
| -- 作者:未知 -- 發佈日期: 2004-12-06 |
| vbs腳本的功能非常強大, 管理系統簡單方便!下面的腳本win2000和winxp都可以使用,win2003沒有測試過,應該也沒有問題。如果需要經常切換網關,或是ip,這個腳本是最方便的了。稍微修改一下甚至可以做到1分鐘變一次ip。
changeip.vbsstrComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each objNetAdapter in colNetAdapters sip=objNetAdapter.IPAddress strIPAddress = sip '保持原來的ip,如果需要修改ip為192.168.0.200:strIPAddress = Array("192.168.0.200") strSubnetMask = Array("255.255.255.0") strGateway = Array("192.168.0.254") '修改網關為192.168.0.254 strGatewayMetric = Array(1) errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) If errEnable = 0 Then WScript.Echo "The IP address has been changed." Else WScript.Echo "The IP address could not be changed." End If exit for '只修改第一個網卡的設置 Next |
| webasp.net |