通过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);
}
}