Want To Hide Command Prompt Window In Using Wshshell.exec Method
I want to execute a java program from a javascript and want to get the output. Intailly i tried with below code: WshShell = new ActiveXObject('WScript.Shell'); var launch='cmd.exe
Solution 1:
Yes, that bother all wsh scripters. No way to hide wshExec
object, only .Run
allow this option, but no StdOut
in this case. Shortly, the only way is to redirect your output to file.
WshShell = new ActiveXObject("WScript.Shell");
var launch ="cmd.exe /c java -classpath . HelloWorld > output.txt";
var cmdRun = WshShell.Run(launch,0,true);
Solution 2:
I know this thread is quite old, but I just came up against the same problem and found a solution by adding "exit" to the command string, which closes the window.
From the cmd page of Microsoft Docs: You can specify multiple commands for [string]. Separate them by the command separator && and enclose them in quotation marks. For example:
"[command1]&&[command2]&&[command3]"
So the full command string you pass to WshShell.Exec would look like this:
cmd.exe /c "java -classpath . HelloWorld&&exit"
Post a Comment for "Want To Hide Command Prompt Window In Using Wshshell.exec Method"