点击按钮,跳出c:\WINDOWS\system32\cmd.exe

解决方案 »

  1.   


    function exe(){
    var sh=new ActiveXObject("Scripting.shell");
    var s="c:\\WINDOWS\\system32\\cmd.exe";
    sh.run(s);
    }
    <input type="button" onclick="exe();" value="open CMD"/>
      

  2.   

    我试着运行了一下,提示错误
    ActiveXObject is not defined
    是什么原因,谢谢!
      

  3.   

    <script>
    var exec=function(command){   
              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;   
          }   
    </script>    
    <input type='button' onclick="exec('cmd')" value='执行'/>
      

  4.   

    哥们,这个问题我之前研究过好久了~代码是很简单的你如:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>    <script type="text/javascript">
            function Run(strPath) {
                exe.value = strPath;
                try {
                    var objShell = new ActiveXObject("wscript.shell");
                    objShell.Run(strPath);
                    objShell = null;
                }
                catch (e) {
                    alert('找不到文件"' + strPath + '"(或它的组件之一)。请确定路径和文件名是否正确,而且所需的库文件均可用。')            }
            }       </script></head>
    <body>
        请输入要运行的程序:<br>
        <input name="exe" type="text" size="20" value="regedit">
        <button type="button" onclick="Run(exe.value)">
            确定</button>
        <button type="button" onclick="exe.value=''">
            重新输入</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\notepad.exe')">
            记事本</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\mspaint.exe')">
            画图板</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\calc.exe')">
            计算器</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\cmd.exe')">
            cmd</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\regedit')">
            Regedit</button><br>
        <button type="button" onclick="Run('G:\\WINDOWS\\system32\\msconfig')">
            Msconfig</button><br>
    </body>
    </html>最关键的是你要更改IE的安全配置,只要你设置你的IE--安全--自定义级别--对为标记的可执行ActiveXObject~  之类的全部不要禁用,,这时候你就看到效果了~~~
      

  5.   

    对了,,我研究这个还写了一篇博客你可以参考下:
    http://hi.baidu.com/jiang_yy_jiang/blog/item/e9e2a8d0707fcd83a1ec9c2b.html
      

  6.   

    firefox 也可以执行ActiveXObject~吗,听说不支持ActiveXObject
      

  7.   

    就是就是 Firefox代码怎么写
      

  8.   

    我按照楼上的方法做了一下,在下面这行有错误提示,automatisierungsserver kann object nicht erstellen.继续求答案,谢谢!var objShell = new ActiveXObject("wscript.shell");