CSDN博客

img kingapex1

获取Mac地址

发表于2004/10/23 3:36:00  1088人阅读

<%@ LANGUAGE="VBSCRIPT"%>
<% 
strIP = Request.ServerVariables("REMOTE_ADDR") 
strMac = GetMACAddress(strIP) 
strHost  = Request.ServerVariables("REMOTE_HOST") 

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   
%> 
<HTML> 
<HEAD> 
<TITLE>Say Hello To the MAC MAN </TITLE> 
</HEAD> 
<BODY> 

阅读全文
0 0

相关文章推荐

img
取 消
img