?
Solved

How to get MAC Address in Script

Posted on 2003-10-26
6
Medium Priority
?
7,543 Views
Last Modified: 2007-12-19
How to get MAC Address in JavaScript or VBScript. Also provide solution if there are two network cards in one system.
0
Comment
Question by:nabilpk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 33

Expert Comment

by:shalomc
ID: 9625858
nabilpk,
You will have to write an ActiveX component and the user will have to agree to it running on the user's PC.

ShalomC
0
 
LVL 2

Accepted Solution

by:
hb21l6 earned 80 total points
ID: 9626569
I use this and this works fine over LAN!!! I have not tested over the net.... (ASP)

<%@ 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      
   
   
    yourIP = strIP
    yourMAC = strMac

if yourIP = "" Then
yourIP = 00
end if


if yourMAC = "" Then
yourMAC = 00
end if

   
%>

let use know if it works.. thanks

hb
0
 
LVL 33

Expert Comment

by:shalomc
ID: 9627936
hb21l6 ,
That is a nice script.
It may do the job, but there are prerequisites:
The server must run IIS, the client must have NetBios enabled, no firewall can be between client and server.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question