Using exec on php/Windows
I tried to run a program with exec() but it just didn’t run. It was a program with several parameters, each parameter escaped with escapeshellarg().
It didn’t do anything, had no return value and no output. After putting a pair of extra quotes around the whole command it worked:
- $cmd = "C:\\do-something.bat $arg1 $arg2";
In the German php documentation I found the hint that exec() executes cmd /c with exec’s first parameter as argument. Therefore the whole command has to be quoted.