配置静态 IP 地址

[ 2005/07/09 10:00 | by gOxiA ]
| |

描述

将计算机的 IP 地址设置为 192.168.1.141,并将 IP 网关设置为 192.168.1.100。


脚本代码
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
   ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
   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
Next

PowerShell & Scripts | 评论(0) | 引用(0) | 阅读(5824)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我