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