[php] php exec() is not executing the command

I have tried to use exec() with 'whoami' to check if it works and I got the result of

nt authority\system

Now I need to run a .exe file with parameters from php via exec() function.

I tried this in command prompt and it actually runs the program with given parameters. This is the example command.


NOTE the exe file gets 3 inputs (folder, file_name, report_file_nmae)

> ..\..\some_file.exe folder="C:\path_to_folder" param=1.xml report=2.xml

But when I run this command from php file:

exec('..\..\some_file.exe folder="C:\path_to_folder" param=1.xml report=2.xml');

nothing is happening. This is the first time I am using exec() function, so I am not familiar with its details. What is wrong?

I tried using:

  • \\ instead of \
  • escapeshellarg() on the directory
  • added "" around directory folder names

No luck

Addendum:

echo exec($command)  // echos < .... why?

or

exec($command, $output);
print_r($output);        // Array()

I even changed the permission on the file to full control to all users. If I call the program from command prompt, I can see the icon appearing next to clock for a second.

But the same call from php will not even call the program.

Edit

Even exec('notepad.exe'); is not working. Something has to be done with php configurations maybe?

This question is related to php windows exec

The answer is


You might also try giving the full path to the binary you're trying to run. That solved my problem when trying to use ImageMagick.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to exec

I do not understand how execlp() works in Linux Running a Python script from PHP How do I execute a Shell built-in command with a C function? What are the uses of the exec command in shell scripts? php exec() is not executing the command How to call execl() in C with the proper arguments? Run Bash Command from PHP PHP shell_exec() vs exec() Ruby, Difference between exec, system and %x() or Backticks How to execute an external program from within Node.js?