2016-08-17 51 views
-1

我需要创建一个简单的HTA应用程序来请求一个命令,然后当我按下一个按钮时该命令应该在命令提示符下执行。javascript hta应用程序作为用于命令提示符的GUI

到目前为止,我只有以下脚本,它只会打开命令提示符窗口,但不会读取并运行输入到文本框中的脚本。

<html> 
<head> 

<HTA:APPLICATION> 

<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); 
} 

</script> 
</head> 

<body bgcolor="grey"> 
<form> 
<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();"> 

</form> 
</body> 
</html> 

回答

0

用途:

shell.ShellExecute("cmd.exe", "/k " + x, "", "open", 1); 
+0

谢谢你这么多为你的帮助:) – student001

+0

谢谢,谢谢。我只是在学习基础知识,你已经帮了很多! – student001

0

很难准确地告诉你要做什么,但我可以告诉你,你从来没有对变量x做任何事情。它似乎正确地检索您的文本区域值,但你从来没有做任何事情。

+0

谢谢你这么多的评论,我会更新你,如果工程:) – student001

+0

谢谢您的输入,上述评论已经回答了我的问题:) – student001

相关问题