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