以下函數可以獲取MAC位址:

'獲取網卡物理位址
Function GetMACAddress(strIP)
Set net = Server.CreateObject("wscript.network")
Set sh = Server.CreateObject("wscript.shell")
sh.run "%comspec% /c nbtstat -A " & strIP & " > c:" & strIP & ".txt",0,true
Set sh = nothing
Set fso = createobject("scripting.filesystemobject")
Set ts = fso.opeNtextfile("c:" & strIP & ".txt")
macaddress = null
Do While Not ts.AtEndOfStream
data = ucase(trim(ts.readline))
If instr(data,"MAC ADDRESS") Then
macaddress = trim(split(data,"=")(1))
Exit Do
End If
loop
ts.close
Set ts = nothing
fso.deletefile "c:" & strIP & ".txt"
Set fso = nothing
GetMACAddress = macaddress
End Function

mac=GetMACAddress("您獲取的IP位址")
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()