yongzhai 发表于 2011-11-16 10:58:53

关于select from的一点疑问

本帖最后由 yongzhai 于 2011-11-17 13:31 编辑

我先定义一个变量$netname为一张网卡的名称,然后通过网卡的名称来获取此网卡的IP,问题是我用以下语句来获取总是失败,返回值为空
$colNIC = $objWMIservice.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2 and name != 'MS TCP Loopback interface'And name != 'VMware Virtual Ethernet Adapter for VMnet8' and name != 'Microsoft TV/Video Connection' and name != '1394 网络适配器'")
For $object in $colNIC
      $netname = StringStripWS($object.name ,1)
Next
$ip = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where Description =" $netname)
for $objext in $ip
      $ipadd = stringstripws($object.ipaddress,1)
next
这个变量在这里应该怎么写,格式有问题还是什么原因

yongzhai 发表于 2011-11-16 11:03:09

有没人知道呀,自己顶一下

devil3380 发表于 2011-11-16 16:45:56

$ip = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where Description =" &$netname)


试下

yongzhai 发表于 2011-11-16 17:34:54

还是不行,获取的IP总是空的

autt 发表于 2011-11-16 21:00:17

只能说你定义有错误{:face (411):}

xms77 发表于 2011-11-16 22:41:54

为什么不用@IPAddress1来获得IP地址?虽然有时候会得到127.0.0.1的IP地址

yongzhai 发表于 2011-11-17 00:38:45

@ipaddress1获取的有时候是0.0.0.N之类的IP,或者是空的,我的代码如下,高手帮我看看
$colNIC = $objWMIservice.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2 and name != 'MS TCP Loopback interface'And name != 'VMware Virtual Ethernet Adapter for VMnet8' and name != 'Microsoft TV/Video Connection' and name != '1394 网络适配器'")
For $object in $colNIC
        $netname = StringStripWS($object.name ,1)
Next
$ip = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where Description =" $netname)
for $objext in $ip
        $ipadd = stringstripws($object.ipaddress,1)
next

yongzhai 发表于 2011-11-17 00:39:49

怎么没人来呀,高手在哪里呀,郁闷.......

tsui 发表于 2011-11-17 07:24:41

$ip = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where Description = '" & $netname & "';")

yongzhai 发表于 2011-11-17 13:31:05

楼上的方法还是不行呀,返回为空

yongzhai 发表于 2011-11-18 11:17:49

贴子不要沉了,问题还没有解决呢

yongzhai 发表于 2011-11-20 18:44:42

晕倒,没人理我呀,
页: [1]
查看完整版本: 关于select from的一点疑问