Ich möchte CMD-Fenster von meiner Webseite (HTML) öffnen. Ich benutze JS, aber etwas stimmt nicht, denn wenn ich drücke, wird die Funktion nicht aufgerufen.Ausführen cmd aus dem Browser - von 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>
EDIT: Ich speicherte es als PHP, und ich habe jetzt einen Fehler in FF:
ActiveXObject is not defined
[Break on this error] var wsh = new ActiveXObject('WScript.Shell');
Thank you!
In welchem Browser? Sie verwenden IE und die Seite ist in einer vertrauenswürdigen Website, richtig? (Oder was auch immer benötigt wird, damit IE potentiell gefährliche Sachen ausführt) –
in IE und FF ... Ja, vertrauenswürdige Website. – Ronny
Und Sie, dass 'eval()' war böse ... –