benkel 发表于 2008-7-1 16:12:34

请教WMI达人,多网卡改IP

$strComputer = "localhost"
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
        $colNetAdapters = $objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
        If IsObj($colNetAdapters) Then
                For $objNetAdapter in $colNetAdapters
                        If BitAND($Return, 1) = 0 AND BitAND($Return, 2) = 0 Then $objNetAdapter.EnableStatic($LocalIPAddress, $strSubnetMask)
                        If BitAND($Return, 4) = 0 Then $objNetAdapter.SetGateways($strGateway, $strGatewayMetric)
                Next
        EndIf
改单个网卡的IP大概是这样,但是如果机子有多个网卡,用AU3调用WMI的话,咋样设置指定网卡的IP呢?请高手赐教!!

benkel 发表于 2008-7-4 16:34:41

GOOKER版主,咋移动"已解决"了?但是还没人回答我问题啊,至少帮忙给个说明啊!表笑我菜了!

Amu 发表于 2008-7-4 22:28:43

$strComputer = "localhost"
$sDescription = "网卡名称"
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
        $colNetAdapters = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = '" & $sDescription & "'", "WQL", 0x10 + 0x20)
        If IsObj($colNetAdapters) Then
                For $objNetAdapter in $colNetAdapters
                        If BitAND($Return, 1) = 0 AND BitAND($Return, 2) = 0 Then $objNetAdapter.EnableStatic($LocalIPAddress, $strSubnetMask)
                        If BitAND($Return, 4) = 0 Then $objNetAdapter.SetGateways($strGateway, $strGatewayMetric)
                Next
        EndIf

songtao 发表于 2009-8-6 00:51:11

学习学习中,

menfan1 发表于 2009-8-6 12:39:41

学习一下。。

bbip 发表于 2009-8-7 16:09:40

WMI看不太明白。。。

yangkaicheng 发表于 2010-1-7 14:44:29

刚来学习的有些看不懂...

非典男人 发表于 2010-1-12 14:22:12

楼主分享下经验哈

zmj2008 发表于 2010-3-14 06:01:38

学习    学习
页: [1]
查看完整版本: 请教WMI达人,多网卡改IP