MAC addresses in JavaScript 1

MAC addresses in 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 = '';
    output = output + '';
    while (!e.atEnd()) {
        e.moveNext();
        var p = e.item();
        if (!p) continue;
        output = output + '';
        output = output + '';
        output = output + '';
        output = output + '';
    }
    output = output + '
CaptionMACAddress
' + p.Caption; +'' + p.MACAddress + '
'; document.getElementById("box").innerHTML = output; } showMacAddress();

Here is what the above code is Doing:
1. Create an ActiveXObject to connect to the WMI service.
2. Query the Win32_NetworkAdapterConfiguration class.
3. Loop through the results and display the Caption and MACAddress properties.
4. Display the results in a table.

The output of the above code is shown below:

Caption MACAddress
Intel(R) 82567LM-3 Gigabit Network Connection 00:1E:90:F9:F8:F0
Microsoft Virtual WiFi Miniport Adapter 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #2 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #3 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #4 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #5 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #6 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #7 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #8 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #9 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #10 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #11 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #12 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #13 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #14 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #15 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #16 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #17 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #18 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #19 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #20 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #21 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #22 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #23 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #24 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #25 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #26 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #27 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #28 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #29 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #30 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #31 00:00:00:00:00:00
Microsoft Virtual WiFi Miniport Adapter #32 00:00:00:

Similar Posts