I have an application which should run a .exe that starts the execution of a scanner . The executable I have in unit C but I can not find any way to execute it.
I have an application which should run a .exe that starts the execution of a scanner . The executable I have in unit C but I can not find any way to execute it.
You have several alternatives:
exec ("c: \ abc.exe", $ result);
And then with a var_dump($resultado);
you can see the result of your program, an element of the array per line sent to stdout.
passthru ("c: \ abc.exe", $ out);
Here the function returns the exit code of the program in $out
Many times the output of the command line is not as "reliable" as one would like, if you do not return the output correctly you may have to consider using pipes to capture everything, this is a little more complicated.
$proceso = proc_open('cmd', [["pipe", "r"], ["pipe", "w"], ["pipe", "w"]], $pipes); //abrimos el proceso cmd.exe proceso con 3 pipes, stdin, stdout y stderr
if (is_resource($proceso)) { //si se ha creado el proceso...
fwrite($pipes[0], '"C:\mis archivos\ejecutable.exe"'); //enviamos comando
fclose($pipes[0]); //cerramos el pipe stdin...
echo stream_get_contents($pipes[1]); //mostramos el output del pipe stdout
fclose($pipes[1]); //cerramos el pipe stdout
echo stream_get_contents($pipes[2]); //mostramos el output del pipe stderr
fclose($pipes[1]); //cerramos el pipe stderr
echo proc_close($proceso); //cerramos el proceso
}
$ out = shell_exec ("c: \ abc.exe");
Here you will have what is sent to stdout in $out
$ out = system ("c: \ abc.exe", $ code)
Finally here you will have what stdout sends in $out
and additionally the exit code of the program in $codigo