I want to execute a java program from javascript and want to get the result.
At first I tried using the code below:
WshShell = new ActiveXObject("WScript.Shell");
var launch="cmd.exe /c java -classpath . HelloWorld ";
var cmdRun = WshShell.Run(launch,0,true);
In the Run method, I cannot get the result of the class.
Then I tried using 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)
{
sleep(100);
}
var output = cmdRun.StdOut.ReadAll();
alert(output);
Now I can get the output in the output of the variable.
My problem is to use the Run method, I can hide commandprompt (by passing the parameters WshShell.Run (start, 0, true)) Where, like using the Exec method, I can not hide commandprompt. I want this commandprompt to be hidden.
Could you help me in this regard? thank
source
share