function GetMac(IP)
On Error Resume Next
Dim oScript
Dim oFileSys, oFile
Dim All, szTempFile,ipc,phyc,typec
Dim TempPath 提示为无效字符,是怎么回事啊?该怎么解决呢?麻烦各位帮忙解决一下吧!
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
TempPath="d:\temp\" '临时目录
szTempFile = TempPath & oFileSys.GetTempName() ' 获取临时文件名
Call oScript.Run ("cmd.exe /c ping -n 2 " & IP, 0, True) '保证arp表中有此IP
Call oScript.Run ("cmd.exe /c arp -a " & IP & " > " & szTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0)
All=oFile.ReadAll()
oFile.Close
If (IsObject(oFile)) Then
Call oFileSys.DeleteFile(szTempFile, True)
End If
arr = Split(All, vbCrLf)
If UBound(arr) = 4 Then
ipc = InStr(1, arr(2), "Internet Address")
phyc = InStr(1, arr(2), "Physical Address")
typec = InStr(1, arr(2), "Type")
If typec > phyc And phyc > ipc And ipc > 0 Then
GetMac=Ucase(Trim(CStr(Mid(arr(3), phyc, typec - phyc))))
End If
End If
End function
那位师傅愿意在线帮我加我QQ:498102685,本人感激不尽,谢谢![此贴子已经被作者于2007-6-11 7:53:50编辑过]