js获取mac地址及ip,获取计算机名称及计算机的用户名

js获取mac地址及ip,获取计算机名称及计算机的用户名(局限:只能用IE浏览器)

IE :工具>Internet选项>安全>Internet>自定义级别>ActiveX控件和插件>对没有标记为安全的ActiveX控件进行初始化和脚本运行,

$(function(){ 

//获得机器名称和机器的登录名 

var WshShell =new ActiveXObject(“WScript.Shell”); 

var computerName = encode64(WshShell.ExpandEnvironmentStrings(“%COMPUTERNAME%”));

 var userName = encode64(WshShell.ExpandEnvironmentStrings(“%USERNAME%”));

 

 //获取mac地址

 var locator = new ActiveXObject(“WbemScripting.SWbemLocator”); 

 var service = locator.ConnectServer(“.”); 

 var properties = service.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE”);

 var e = new Enumerator(properties); 

 for (; !e.atEnd(); e.moveNext()){ 

var p = e.item(); 

 if(p.IPAddress(0)!=null && p.IPAddress(0)!=”undefined” && p.IPAddress(0)!=”0.0.0.0″ && p.IPAddress(0)!=”127.0.0.1″){ 

$(“#macAddr”).val(p.MACAddress); 

$(“#ip”).val(p.IPAddress(0));break;

 } 

}

}

)

若涉及到加密:http://www.52pojie.cn/forum.php?mod=viewthread&tid=348220 该文章不错

    原文作者:飞鸟的心情
    原文地址: https://blog.csdn.net/u014792342/article/details/52475520
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞