开发者

show output from shell command run from Jscript

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("WSc开发者_JS百科ript.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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜