show output from shell command run from Jscript

╄→гoц情女王★ 提交于 2019-12-10 21:28:51

问题


I want to run a shell command from jscript from IE on a Windows machine.

I have the following jscript function:

function execCommand( command ){
    var myShell =  new ActiveXObject("WScript.Shell");
    myShell.Exec( "cmd /c " + command );
}

Under Windows, a new prompt window opens, the command is executed, and the window closes. Nevertheless, the prompt never shows any of the output from the command. While the command is running there is a blank prompt window.

How can I force the output of the program to show in the prompt window?

I have searched other questions, but I only found solutions for scripts running inside Windows Scripting Host, or for jscript javascript running in Mozilla.

I appreciate any hints.


回答1:


You can use the methods described here.

By exec you have to echo the stdout into a new message, by run you can use cmd or %comspec% with /K to prevent the window closing.

You should try the pause command too, maybe it helps...



来源:https://stackoverflow.com/questions/6275761/show-output-from-shell-command-run-from-jscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!