天天看點

配置靜态 IP 位址

描述

将計算機的 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

本文轉自 蘇繁 51CTO部落格,原文連結:http://blog.51cto.com/goxia/221140,如需轉載請自行聯系原作者

繼續閱讀