用vbs实现配置静态 IP 地址
更新时间:2007年05月14日 00:00:00 作者:
将计算机的 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
脚本代码
复制代码 代码如下:
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教程:方法-GetAbsolutePathName 方法
VBS教程:方法-GetAbsolutePathName 方法...2006-11-11VBS基础篇 - VBScript过程(使用sub 与 Function定义函数)
在 VBScript 中,过程被分为两类:Sub 过程和 Function 过程,需要的朋友可以参考下2018-05-05vbs打开ie两种方法 在VBScript中启动IE浏览器的实现代码
用VBS打开网页,减少IE广告, 不错的东东,是在网上收集的,你也可以实现网页的自动登录等2013-01-01
最新评论