js调取本地可执行文件exe


通过ie支持的activex控件来读取文程序的安装路径,从而调用本地exe文件

function callExe () {
try{
var command;
var shell = new ActiveXObject("WScript.Shell");
command = shell.RegRead("HKEY_CURRENT_USER\\SOFTWARE\\Tencent\\WeChat\\InstallPath");//从注册表获得软件安装路径
command = command + "\\WeChat.exe";
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令' + window._command + ' 已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh){
wsh.Run("\""+command); //解决目录包含空格问题
}
window.onerror = window.oldOnError;
}catch(e){
alert(e);
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM