Reputation: 17666
I'm attempting to run an application on the server, invoking it from PHP using the following code.
$application = "D:\\Program Files (x86)\\ScanBoy\\DM ScanBoy.exe";
exec($application);
Right now the application is 'run' however it crashes instantly. If I just run the application (by double clicking the exe) it runs and everything is fine.
When the application crashes the only error I get is
"{application name} has stopped working. Windows is checking for a solution to the problem"
I have had this problem with running application via c# backend to a ASP.NET page. The solution there was to set the Working Directory. However in php / exec I am unaware of how to set this option.
Any help please?
Upvotes: 0
Views: 340
Reputation: 5475
You can either:
Use exec("cd myworkdir/ && D:\\Program Files (x86)\\ScanBoy\\DM ScanBoy.exe");
to change the working directory for that exec command (only)
Use the php chdir()
function to change the working directory of the php process.
You can find chdir
documentation here:
http://php.net/manual/en/function.chdir.php
Upvotes: 2