execute()

Function that calls an external program and waits for it to end.

execute(command)

Calls an external program and waits for it to end.

command

String that specifies the path and file name of the program to execute.

How to get the exit value or output

It is possible to retrieve the exit value or the output of the execute() function by executing the getExitValue() function or getInputStreamReader() function, respectively.

Example

Copy
var ex = execute("ipconfig");
var exitValue = ex.getExitValue(); // Exit value is equal to 0 when OK
var reader = ex.getInputStreamReader(); // Reader for outputvar error
Reader = ex.getErrorStreamReader(); // Reader for error
// Read all output lines into text
var txt = "";
var line = reader.readLine();
while (line != null) {
    txt += line.trim();
    line = reader.readLine();
}