博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Win32_NetworkAdapterConfiguration
阅读量:4322 次
发布时间:2019-06-06

本文共 1323 字,大约阅读时间需要 4 分钟。

 

 1 
    strComputer 
=
 
"
.
"
 2 
    
Set
 objWMIService 
=
 
GetObject
(
"
winmgmts:\\
"
 
&
 strComputer 
&
 
"
\root\cimv2
"
)
 3 
    
 4 
'
    Set colNetAdapters = objWMIService.ExecQuery (_
 5 
'
        "Select * from Win32_NetworkAdapterConfiguration Where Index=8")
 6 
'
   Index=8,导致硬件更换后网卡序列号不对。
 7 
    
Set
 colNetAdapters 
=
 objWMIService.ExecQuery (_
 8 
        
"
Select * from Win32_NetworkAdapterConfiguration where IPEnabled=True
"
)
 9 
    
10 
    strIPAddress 
=
 
Array
(
"
192.168.188.109
"
)
11 
    strSubnetMask 
=
 
Array
(
"
255.255.255.0
"
)
12 
    strGateway 
=
 
Array
(
"
192.168.188.100
"
)
13 
    strGatewayMetric 
=
 
Array
(
1
)
14 
'
    If colNetAdapters Is Nothing Then
15 
'
        MsgBox "不能创建colNetAdapters对象。"
16 
'
    End If 
17 
    
18 
    
For
 
Each
 objNetAdapter in colNetAdapters
19 
'
        WScript.Echo objNetAdapter.Caption  'Atheros AR8131 PCI-E Gigabit Ethernet Controller
20 
        
'
修改指定网卡的IP
21 
        
If
 
Left
(objNetAdapter.Description,
Len
(
"
Atheros AR8131
"
))
=
"
Atheros AR8131
"
 
Then
 
22 
            errEnable 
=
 objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
23 
            errGateways 
=
 objNetAdapter.SetGateways(strGateway, strGatewaymetric)
24 
        
End
 
If
 
25 
    
Next
26 
    
27 
'
    参考资料:
28 
'
    http://social.msdn.microsoft.com/Forums/zh-CN/windowssdk/thread/466fa3b8-9179-4244-9b83-5f8ffc6825bc
29 
'
    http://topic.csdn.net/u/20100720/17/08148f61-926a-4a94-8ebd-3edcde9a5c0a.html

 

转载于:https://www.cnblogs.com/jevan/archive/2011/03/01/1967734.html

你可能感兴趣的文章
ORA-15260: permission denied on ASM disk group
查看>>
Linux中seq命令的用法
查看>>
HTTP协议的chunked编码
查看>>
画原型是节省人力的最好办法
查看>>
shell(十)排序
查看>>
Operating System-进程间互斥的方案-保证同一时间只有一个进程进入临界区(2)- Peterson解法...
查看>>
1.1 Friday the Thirteenth
查看>>
VS 高亮显示不带后缀的C++头文件
查看>>
python基础之面向对象
查看>>
Abnormal build process termination--解决IDEA启动web项目报错
查看>>
JS设计模式之工厂模式
查看>>
Git忽略规则及.gitignore规则不生效的解决办法
查看>>
EasyUI 搜索框
查看>>
impdp and docker install oracleXE
查看>>
入门训练 序列求和
查看>>
web前端_Vue框架_设置浏览器上方的标题和图标
查看>>
gnome3 隐藏标题栏
查看>>
duilib入门简明教程 -- 第一个程序 Hello World(3) (转)
查看>>
Visual Studio 2008下载
查看>>
hdu1712: ACboy needs your help
查看>>