当前位置: 代码迷 >> JavaScript >> JS施行本地.exe程序
  详细解决方案

JS施行本地.exe程序

热度:449   发布时间:2012-11-25 11:44:31.0
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>
?
  相关解决方案