【发布时间】:2018-10-13 10:29:34
【问题描述】:
我在我的 HTA 文件中运行一些 CMD 命令,例如
<script>
var WShell = new ActiveXObject('WScript.Shell');
WShell.run('cmd /c the_first_command');
WShell.run('cmd /c the_second_command');
</script>
第一个命令可能需要一段时间才能完全执行,例如几秒钟
只有在 CMD 输出显示上一个任务已完全完成后,我才需要运行下一个命令。
据我所知,在第一个命令之后我可以运行一个间隔
var timer = setInterval(function() {
var cmd_output_of_the_first_command = ???;
if(~cmd_output_of_the_first_command.indexOf('A text about the task is completed')) {
clearInterval(timer);
WShell.run('cmd /c the_second_command');
}
}, 500);
那么问题是如何获取 CMD 输出?
【问题讨论】:
标签: cmd activex jscript wsh hta