本帖最后由 landays 于 2009-10-25 21:11 编辑
源码:$MyMac = mac()
MsgBox (64,"",$MyMac)
$RepWr = StringReplace ($MyMac,":","-")
MsgBox (64,"",$RepWr)
$Cfg = @ScriptDir & "\eGoIP.ini"
$eGoIP = IniRead ($Cfg,"MACLIST",$RepWr,"")
MsgBox (64,"",$eGoIP)
;读取Mac
Func mac()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
$Output1 = $Output & "" & $objItem.MACAddress & @CRLF
Next
Return $Output1
Else
Endif
EndFunc
配置文件:eGoIP.ini
[MACLIST]
00-E0-4D-3B-55-DC=A001,192.168.0.11
mac()读取出的MAC与配置文件里的一样
但是为何读不出结果? |