Solved

How to get MAC Address in Script

Posted on 2003-10-26
6
7,536 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 20 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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
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.

738 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