phoenixx
phoenixx

Reputation: 41

PHP exec causes program to crash

I'm using a program called Do It Again which is a mouse recorder. I am trying to launch a shortcut to it from my php script. Seems all is okay when I run it as a stand alone program, and is not set to have to be run by the administrator - still when I launch it from my php page I get the windows popup saying the program has crashed. "DoItAgain.exe has encountered a problem and needs to close. We are sorry for the inconvenience."

It's not the program, but something in my code:

$command= 'C:\\xampp\htdocs\poster\dia\\Monty_20.dia';
exec($command);

I also tried the following but get the windows popup error: "The Application Failed to Initiate Properly"

$command= ('START C:\\xampp\\htdocs\\poster\\dia\\Monty_20.dia');

Any help would be greatly appreciated. I've been at it for 3 hours now and I'm pulling out what little hair I have left.

Upvotes: 3

Views: 716

Answers (1)

Brigand
Brigand

Reputation: 86270

Try copying your command to the clipboard. Press Windows-R to get a run dialog, where you paste it and click Run. If you get the same error, the problem is PHP related or permission related.

The more likely case is the program just isn't working. In that case someone who has experience with Do It Again could be more helpful. (Their forum, perhaps?)


Based on the exec docs, it may help to redirect output.

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

So your command would need to redirect the output to the null device. I don't use windows but I believe it would be something like C:\path\to\my.exe > NUL.

Upvotes: 1

Related Questions