Search code examples
javascripthtmlwscript.shell

Send input value in WScript.Shell inside HTA application


I'm trying to make a restart application that takes seconds from the HTML input button and sends it to JS function which contains WScript.Shell.

<script>
function languages(){
  var test = document.getElementById("myInput").value;

  var shell = new ActiveXObject("WScript.Shell");
  var path = "shutdown -r -t " & test;
  shell.run(path,1,false);
}
</script>
<div align="center">
  <img src="restartICO.png" />
  <br>
  <br>
  <input id="myInput" type="number" />
  <br>
  <br>
  <br>
  <br>
  <button class="blokirebaARA2" onclick="languages();"
    title="შლის ენებს და ამატებს ხელახლა GE & RUS">GE-RUS</button>&nbsp;&nbsp;&nbsp;
</div>

I don't know how to pass variable correctly in htis format


Solution

  • This is how you send variables inside HTA application:

    function restart(){
      var testr = document.getElementById("myInput").value;
      if (testr == "") {
      var shell = new ActiveXObject("WScript.Shell");
      var path = "shutdown -r -f -t 0";
      shell.run(path,1,false);
      }
      else {
      var shell = new ActiveXObject("WScript.Shell");
      var path = "shutdown -r -f -t " + testr;
      shell.run(path,1,false);
      }
    }
    

    var path = "shutdown -r -f -t " + testr