I want to execute a java program from a javascript and want to get the output.
Initially I tried with the code below:
WshShell = new ActiveXObject("WScript.Shell");
var launch = "cmd.exe /c java -classpath . HelloWorld ";
var cmdRun = WshShell.Run(launch, 0, true);
Through Run method i am not able get the output of the class.
Then I tried with the code below:
WshShell = new ActiveXObject("WScript.Shell");
var launch = "cmd.exe /c p java classpath . HelloWorld ";
var cmdRun = WshShell.Exec(launch);
while (cmdRun.Status == 0) // wait for the command to finish
{
sleep(100);
}
var output = cmdRun.StdOut.ReadAll();
alert(output);
Now I am able to get the output in variable output.
My problem is using Run method I can hide the command prompt by passing parameters WshShell.Run(launch, 0, true), while by using Exec method I am not able to hide the command prompt. I want this command prompt to be hidden.
Can you please help me in this regard? Thanks