JS get the physical address of the client network card (MAC)

Source: Internet
Author: User
Tags command line window client
js| Client

First, we know that there are several ways to manually view MAC addresses (the operating system I use is Windows XP):

1. Click on the menu "Start-All Programs-accessories-System Tools-System Information", then click "Component-Network-adapter" in the pop-up window, wait a moment, we can see the details of the network adapter on the right, including the MAC address.


2. Open the "Run" dialog box entered "CMD", and then in the Open Command Line window to enter "Ipconfig/all", press ENTER to find "Physical Address" item, this is the MAC addresses of the network card.

So what if you use a program to implement it? Here is a word about the implementation of JS, the following program to run before, please do the following settings:

Open IE tools-internet option-security-Custom Level-initializes the ActiveX control that is not marked as safe ...
Set this option to prompt


<script language= "JScript" event= "oncompleted (Hresult,perrorobject, Pasynccontext)" for= "foo" >
document.write (unescape (MACADDR));
</SCRIPT>
<script language= "JScript" event= "OnObjectReady (objobject,objasynccontext)" for= "foo" >
if (objobject.ipenabled!= null && objobject.ipenabled!= "undefined" && objobject.ipenabled = = True & & objobject.macaddress!= null && objobject.macaddress!= "undefined")
MACADDR = objobject.macaddress;
</SCRIPT>
<object id= "locator" classid= "Clsid:76a64158-cb41-11d1-8b02-00600806d9b6"
Viewastext></object>
<object id= "foo" classid= "clsid:75718c9a-f029-11d1-a1ac-00c04fb6c223" ></OBJECT>
<script language= "JScript" >
var service = Locator. ConnectServer ();
var macaddr;
var ipaddr;
var domainaddr;
var sdnsname;
Service. Security_. impersonationlevel=3;
Service. Instancesofasync (foo, ' Win32_NetworkAdapterConfiguration ');
</SCRIPT>


Run the above program, you can see the network card address



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.