星猫大富翁单机版下载:如何ASP取出MAC地址

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/13 00:50:53
[急求]如何能ASP取出MAC地址?
请问:
1、sh.run "%comspec% /c nbtstat -A " & strIP & "> c:\" & strIP & ".txt ",0,true
提到的“%comspec%”代表什么?
2、如果此人的IP是自动拨号的,不听的在换,我怎么样才能回访他的MAC地址呢

  js是在客户端运行的,asp代码是在服务器运行的, 没有办法获得客户端的mac。

  用javascript就可以,参考代码如下:

function getMac(){
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =True");
      var e = new Enumerator (properties);
      {
            var p = e.item();
            var mac = p.MACAddress;
            return mac
      }
}
 
alert(getMac())

<%@ 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>
<%Response.Write("Your IP is:" & strIP & " " & vbcrlf)%>
<%Response.Write("Your MAC is:" & strMac & vbcrlf)%>
</BODY>
</HTML>