主要实现功能: 在 "192.168.0.120" and "192.168.0.8" 之间切换网关地址
有几点需要注意的:
1. 带返回值函数需声明变量来接收其返回值。否则如 objItem.EnableStatic(strIPAddress, strSubnetMask)不给定返回值将出现
编译器错误: 调用过程(Sub)时不能使用括号
(为什么?)
2.对于变量数据类型为数组的数据,有三种访问方式:
法一:直接用循环遍历数组
' For Each strIPAddress in objItem.IPAddress
' WScript.Echo strIPAddress
' Next
法二: 用数组上下标作为循环变量取值范围遍历
For i=LBound(objItem.IPAddress) _
to UBound(objItem.IPAddress)
...
Next
法三:直接给定数组下标,如
WScript.Echo strGateway(0)
本程序缺陷:
显示本地连接属性时前后代码重复,可用函数来代替
当然,还有更简单的命令行方法