J D OConal
J D OConal

Reputation: 624

PHP exec on Windows Server 2008

I have installed PHP as a module in IIS on Windows Server 2008, am am having great difficulty trying to execute command-line programs from within a PHP script.

I can execute the PHP code fine using php-cgi.exe and php-cli.exe, which leads me to believe that it might be a permissions issue.

However, I can execute some commands, like shutdown.exe and dir.

I have tried the same process in an ASP.NET file and am having exactly the same problem.

Basically, I would like to do this:

exec("path-to-exe-file");

And actually have it work.

Upvotes: 3

Views: 2818

Answers (2)

user2000755
user2000755

Reputation: 1

I spent several hours before realising what was wrong...

Use IIS Manager, Application Pools, select the pool associated to your application and make sure that:

ProcessModel.Identity = LocalSystem

and

ProcessModel.Load User Profile = true

Upvotes: 0

VolkerK
VolkerK

Reputation: 96159

Try

exec('path-to-exe-file 2>&1', $output);
var_dump($output);

The 2>&1 part should redirect error messages to stdout (on win32, too) which therefore should show up in $output.

Upvotes: 1

Related Questions