student001 student001 - 1 year ago 281
Bash Question

javascript hta application as GUI for command prompt

I need to create a simple HTA application that will ask for a command, then when I press a button that command should be executed in command prompt.

I have the following script so far which will only open a command prompt window but not read and run the script entered into the text box.



<script type="text/javascript" language="javascript">

function Run() {

x = document.getElementById("command").value;
shell = new ActiveXObject ("Shell.Application");
shell.ShellExecute("cmd.exe", "/k ", "", "open", 1);


<body bgcolor="grey">
<h1> Enter MS-DOS Command </h1>
<p> eg: ipconfig </p>

<textarea cols="20" rows="1" id="command"> </textarea> <br> <br>

<input type="button" value="Run" onclick="Run();">


Answer Source


shell.ShellExecute("cmd.exe", "/k " + x, "", "open", 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download