从浏览器运行cmd - 由JS

Ron*_*nny 2 html javascript cmd

我想从我的网页(HTML)打开cmd窗口.我正在使用JS,但有些东西是不对的,因为当我按下时,该函数不会被调用.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
<!--
function runCmd(command, option)
{
    var char34 = String.fromCharCode(34);
    var wsh = new ActiveXObject('WScript.Shell');
    if (wsh)
    {
        command = 'cmd /k ' + char34 + wsh.ExpandEnvironmentStrings(command) + ' ';
        command = command + char34 + wsh.ExpandEnvironmentStrings(option) + char34  + char34;
        if (confirm(command))
        {
            wsh.Run(command);
        }
    }
}
//-->
</script>
</head>

<body>

<input type="button" value="Run!" onclick="runCmd(‘notepad.exe’, ‘%programfiles%\file.txt’);" />
</body>
</html> 
Run Code Online (Sandbox Code Playgroud)

编辑: 我保存为PHP,现在我在FF中有错误:

ActiveXObject is not defined
[Break on this error] var wsh = new ActiveXObject('WScript.Shell'); 
Run Code Online (Sandbox Code Playgroud)

谢谢!

Gar*_*eth 9

您必须基本上关闭浏览器中的所有安全功能(需要使用各种Internet Explorer才能使用ActiveX).

大多数浏览器都不允许这种事情,你能想象如果[互联网上的随机人员]只是通过让你访问网页就可以在你的计算机上运行任何他们想要的东西吗?