问题
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