0
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
            var service = locator.ConnectServer(".");
            var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
            var e = new Enumerator(properties);
            var MACaddress = '';
            alert("Its Inside");
            for (; !e.atEnd(); e.moveNext()) {
                var p = e.item();
                if (p.MACAddress) {
                    MACaddress = MACaddress + p.MACAddress + ',';
                }
            }
            MACaddress = MACaddress.substring(0, MACaddress.length - 1);
            MACaddress = replaceAll(MACaddress, ':', '-');
            location.href = location.href + '?CAT=MAC&MACAddr=' + MACaddress;

This function is working fine in IE but its breaking in mozilla firefox at the first line itself. I changed locator.ConnectServer(".") to locator.ConnectServer("MACHINE") but still its not working in Mozilla Firefox.

user1199842
  • 151
  • 2
  • 14

1 Answers1

2

Simple answer: you can't.

Modern browsers sandboxes (or try to) everything that goes on in the browser for security reason. Sand-boxing prevents any direct access to a system incl. files system, hardware etc. (it doesn't mean the browser does not communicate with the hardware but as users we have not direct access to it).

IE is the only browser which supports ActiveX (which is Microsoft's own technology) but it shouldn't be relied upon for the same reason, (mainly..) security.

If you want to use the MAC-address for some sort of unique identifier/security you can instead look into the new Web Cryptography API, however, at the time of this writing it is still in draft mode and not widely supported (but will be, or intents to be, cross-browser sometime in the future) so perhaps not so very useful advice at the moment.

You can in any case use server side to generate a unique identifier based on various factors and store it locally in the browser using either cookies or localStorage and so forth.