开发者

using phps exec command to launch an application on the server

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?


You can either:

  1. Use exec("cd myworkdir/ && D:\\Program Files (x86)\\ScanBoy\\DM ScanBoy.exe"); to change the working directory for that exec command (only)

  2. 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


You can chdir() to change current working directory

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜