在DOS行下设置静态IP

来源:百度知道 编辑:UC知道 时间:2024/06/01 10:21:39
A.设置静态IP
CMD
netsh
netsh>int
interface>ip
interface ip>set add "本地链接" static IP地址 mask gateway
B.查看IP设置
interface ip>show address
请问到这句话该怎么设置 "interface ip>set add "本地链接" static IP地址 mask gateway"

set address static 10.0.0.9 255.0.0.0 10.0.0.1
set address 静态 ip地址 子网掩码 网关

用脚本
On Error Resume Next
strComputer = "."
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 = Array(IpAdd) '保持原来的ip,如果需要修改ip为192.168.0.200:strIPAddress = Array("192.168.0.200")
strSubnetMask = Array(Mask)
strGateway = Array(GateWay) '修改网关为192.168.0.254
strGatewaymetric = Array(1)

errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
MsgBox "The IP address has been changed.&qu