I’m trying to run file_creator.exe
via PHP which accepts some arguments and produces an output file. so how can I get the name of output file in order to produce the download link?
Advertisement
Answer
You will want to use shell_exec() function in PHP (http://php.net/manual/en/function.shell-exec.php) to run your exe file. Pass in the parameters in the command line such as:
<?php $outputOfExecutable = shell_exec("C:\path\to\cmd.exe /c C:\batchfile.cmd"); ?>
Whatever your executable returns at the end of it’s execution is returned to your PHP script. This means that your executable should return the path of the file it generated so you can actually read it with PHP or it could return the file content and you write it to disk, it’s as you wish.