MAC Address Using WMI on Internet Explorer
By Umar Farooq
Views: 126977

This article helps you in finding the MAC address of a client machine on IE using WMI Library
MAC Address Using WMI on Internet Explorer (Page 1 of 1)
In this little article, i will help you in finding the MAC address from javascript with the help of WMI Library. The script runs only on IE with the following limitations
  • Works on Internet Explorer only
  • Internet Explorer security settings should allow creating ActiveX Objects
  • WMI scripting library is installed on the client machine
Setting IE Security Level
First of all you will need to change the security settings of IE, allowing the following two options
  • Initialize and script ActiveX controls not marked as safe for script -> Set it to enable or prompt
  • Run ActiveX controls and plugins -> Set it to enable or prompt
To change these two options, go to Tools -> Internet Options -> Security -> Custom Level Screen Shot1  Screen Shot2

Installing WMI scripting library
The next step is to install WMI Library, you can download it for free from the Microsoft website. WMI Library can be downloaded from

What is WMI scripting library?
The WMI scripting library provides the set of automation objects through which scripting languages, such as VBScript, JScript, and ActiveState ActivePerl access the WMI infrastructure. The WMI scripting library is implemented in a single automation component named wbemdisp.dll that physically resides in the systemroot\System32\Wbem directory. (description from

At the top of the WMI scripting library object model is the SWbemLocator object. SWbemLocator is used to establish an authenticated connection to a WMI namespace, much as the VBScript GetObject function and the WMI moniker "winmgmts:" are used to establish an authenticated connection to WMI. However, SWbemLocator is designed to address two specific scripting scenarios that cannot be performed using GetObject and the WMI moniker.(description from Read More >>

The whole script is given below, just copy this script and execute in IE only.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting MAC Address From Javascript(IE Only)</title>
<script language="javascript">
function showMacAddress(){
	var obj = new ActiveXObject("WbemScripting.SWbemLocator");
	var s = obj.ConnectServer(".");
	var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
	var e = new Enumerator (properties);

	var output;
	output='<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">';
	output=output + '<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';

		var p = e.item ();
		if(!p) continue;
		output=output + '<tr bgColor="#FFFFFF">';
		output=output + '<td>' + p.Caption; + '</td>';
		output=output + '<td>' + p.MACAddress + '</td>';
		output=output + '</tr>';

	output=output + '</table>';
	<input type="button" value="Show MAC Address" onclick="showMacAddress()" />

	<div id="box">

This article is about highlighting different features (schools, airports, government places, worship places, bus, rail, parks, hospitals etc) on the Google map. . Read More Highlight Features (Airport, Hospital, Bus, Rail, Park, School etc) on Google Map


hi, Script is very good and working fine. But i would like to display one MAC Id, which is unique in any system. How can i get? Thanks and Regards sree

šelik šatı

WOW, lol this is working fine, but question to "do you want to work it?" This is wonderful!


Hi. This script work great. I dont know if is possible to write this for others browsers. what language i have to use for make this in other browser?


I need mac address using php...And it has to work all os.please...........


It does work for my IE7


@deva Impossible! PHP is a server side language it cant access the MAC address of a client.


Hi Tk is very good.....excelent, one question Print Text in Object ActivexObject is possible ???? 


hm.. great..

btw could u get MAC Address Using WMI on other browser???

thank's b4... ^_^


It works ok, but the line "e.moveNext();" needs to be at the end of the while block, otherwise it will skip the first item on the list.


On firefox doesn't work?

Tractari bucuresti

Need any external ActiveX controls?


it is not working in ie8 the following error is comming 

Microsoft JScript runtime error: Automation server can't create object



Has anyone been able to put all this data in form fileds and do a POST to a server ? I would like to save tihs data on the server side to make sure it is the same machinea accessing my system after purchasing a license.


Thanks in advance....i am getting an error like "Automation Server can't create object " plz help.....


Great !! it is working . Anybody know how to get MAC address by running a javascript , at the same time without the setting "Initialize and script ActiveX controls not marked as safe for script "-> Set it to enable or prompt

Md Ali


When I run this code on my local machine, its working fine, but when I publish it to any hosting site, then it not working.


Please help me on this matter.


wow it worked thanks alot

Sandeep DiL

I have tested that script and it doesn't work for me..

Tested result
Opera v12.13 => Not working

Mozilla v18.0.2 => Not Working

Chrome v24.0.1312.57 => Not Working

IE v10.0.9200 => Not Working

Is short  ..... NOT WORKING..................................................


can I get mac address in C# .Net and in codeigniter????????????????


please rly me as fast as you can.....

celik konstruksiyon

very thanks...

Jahangir Khan

The script is very good, but i need this script to work in all kind of explorers, specially Google Chrome and Fire fox. Please define this script for all explorers. Thanks.

Posting comments has been disabled temporarily