Solved

How to get MAC Address in Script

Posted on 2003-10-26
6
7,527 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to replace a token in a string with square brackets? 2 56
WEB Farm 6 66
modify h2 4 89
Not seen Link button 5 19
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now