首页 > Web开发 > 详细

用vbs实现配置静态 IP 地址

时间:2016-01-21 08:53:17      阅读:189      评论:0      收藏:0      [点我收藏+]
将计算机的 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 

用vbs实现配置静态 IP 地址

原文:http://www.jb51.net/article/9954.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!