set "select=" set/p select= 輸入數字,按回車繼續 : if "%select%"=="0" (goto sc_ip0) if "%select%"=="1" (goto sc_ip1) if "%select%"=="Q" (goto sc_exit)
:sc_exit exit goto :eof
:sc_ip0 cls echo 正在設置中,請稍候 Netsh interface IP Set Address "本地連接" Static 192.168.0.99 255.255.255.0 192.168.0.1 1 Netsh interface IP set dns "本地連接" static 192.168.0.1 primary echo 設置成功 192.168.0.99 PAUSE >nul Goto sc_main :sc_ip1 cls echo 正在設置中,請稍候 Netsh interface IP Set Address "本地連接" Static 192.168.1.99 255.255.255.0 192.168.1.1 1 Netsh interface IP set dns "本地連接" static 192.168.1.1 primary echo 設置成功 192.168.1.99 PAUSE >nul Goto sc_main
vbs修改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