Calling Excel from PHP 5 through COM fails on Windows 7 when Apache started through Task Planner Calling Excel from PHP 5 through COM fails on Windows 7 when Apache started through Task Planner apache apache

Calling Excel from PHP 5 through COM fails on Windows 7 when Apache started through Task Planner


Go into the task planner and let everything run as a local user. This will probably require that you enter a password so create one if you don't have one already.

Excel is a user-level application that shouldn't run as SYSTEM. I'm sure there are ways around it, but you should simply let everything run at the correct level.

Having Apache run on the user level isn't a problem.


Try creating the following directories:

C:\Windows\SysWOW64\Config\Systemprofile\DesktopC:\Windows\System32\Config\Systemprofile\Desktop

it worked for me :-)

http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91


In the past (read: pre Vista) services had an option called "Allow Service to interact with desktop" which allowed services to spawn windows etc. Starting Vista, this is no longer allowed.

I suspect Excel is failing because it can't function under this restriction. Thus, any attempt to run it as a service in your Win7 installation will fail.

You can Windows XP and allow desktop interaction for your Apache process, which I don't really recommend for obvious reasons.

Another approach I would take is to create a PHP script that runs as a regular process and listens on a socket in an infinite loop. Your PHP script that runs under Apache would communicate with the secondary script through the local socket and have the secondary script spawn Excel.

This may sound complicated but in fact it's not a lot of code and it fixes a problem you will soon have anyway: You should only have one instance of Excel running or you may run into problems. The secondary script could queue requests, handing off one by one to Excel then taking the next in the queue.