日期:2014-05-16  浏览次数:20344 次

JS执行本地.exe程序
  <script type="text/javascript">
    function exec (command){    
        try{  
            alert('找到啦!文件"'+command+'"(或它的组件之一).')        
            var objShell = new ActiveXObject("wscript.shell");       
            objShell.Run("C:\\Windows\\regedit.exe");       
            objShell = null;       
        }catch(e){    
            alert('找不到文件"'+command+'"(或它的组件之一).')       
        }      
    }     
  </script>

?

  <script>
     function hello () {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
        file.initWithPath("D:/program files/foobar2000/foobar2000.exe");
        file.launch();
     }
     function hello() {
        var oURL = "www.baidu.com";
        
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess);
        var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
        
        targetFile.initWithPath("D:/temp/1.exe");
        process.init(targetFile);
        var arguments = [oURL];  //arguments参数必须是数组,否则下面语句不执行
        process.run(false, arguments, arguments.length,{});
     }
   </script>
?