js调用本地 exe

function Run(strPath)  //only for ie
{   
           try   
           {   
             var objShell = new ActiveXObject("wscript.shell"); 
             objShell.CurrentDirectory="E:\\YOURPATH\\C++\\CHelloWord 3\\Debug\\";
             //设置当前路径很重要,能让exe程序解决 相对路径问题 (否则会在html所在路径找)
             objShell.Run(strPath);   
             objShell = null;   
           }  catch(e){ 
                alert(e.message);  
           }   
 
} 
    
<a href="#" onclick="Run('CHelloWord3.exe')">RUN EXE</a>   

 

posted @ 2019-03-28 11:21  小猫钓鱼吃鱼  阅读(312)  评论(0编辑  收藏  举报