title: Run cmd from browser - by JS
body: <p>I want to open cmd window from my web page(HTML). I'm using JS but something is not right because when i press, the function isn't called.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!--
  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);
          }
      }
  }
  //--&gt;
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;input type="button" value="Run!" onclick="runCmd(‘notepad.exe’, ‘%programfiles%\file.txt’);" /&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p><strong>EDIT:</strong>
  I saved it as PHP and now i have an error in FF:</p>
  
  <pre><code>ActiveXObject is not defined
  [Break on this error] var wsh = new ActiveXObject('WScript.Shell'); 
  </code></pre>
  
  <p>Thank you!</p>