js调用本地 exe

 

js方法 

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

html调用

<a href="#" onclick="Run('CHelloWord3.exe')">RUN EXE</a>    

  

posted @ 2015-04-10 11:36  人来人往  阅读(2277)  评论(0编辑  收藏  举报