Excel call with PHP 5 via COM fails on Windows 7 when starting Apache through Task Planner

Hi, this question cannot be too complicated. Please provide a solution to at least find out the root cause of the problem.

I am currently writing an application that manages Excel through COM : the application creates an instance of Excel based on COM, opens some XLS files and reads their contents.

Scenario I

On Windows 7, I start Apache and mySQL using xmapp-control with system administrator privileges . Everything works as expected. A PHP script based controller interacts with Excel as expected.

Scenario II

There is a problem if I run Apache and mySQL as background jobs. Here's how:

  • I created two jobs using the Windows 7 Task Scheduler . One runs apache_start.bat, the other runs mysql_start.bat.
  • Both tasks run as SYSTEM with elevated privileges when loading Windows 7.

Apache and mySQL work as expected. In particular, Apache serves an HTTP request from clients, and PHP can talk to mySQL.

When I call a PHP controller that calls and interacts with Excel using COM, I get an error.

The error message is output from Excel [not COM itself] and read as follows:

  • Excel cannot read the specified Excel file
  • Excel could not save the file due to a sheet with the wrong name.

, PHP script . .

Windows .

, PHP Apache - , Apache.

, PHP- script , XLS scandir() .

Concurrency . PHP Excel.

- , ? (, PowerShell 2 script)?

UPDATE-1:: 2011-11-29

, SYSTEM . . Apache MySQL .

, Excel . , .

, EXCEL COM. (, ) COM-.

:

$excelComObject->Workbooks->Open( 'PathToXLSFile' );

UPDATE-2:: 2011-11-30

USER, GUEST EVERYONE READABLE XLS. .

, PHP XLS . , /.

.

UPDATE-2:: 2011-12-05

EXCEL COM-Server , Excel /tmp. , Excel .

+5
3

(: pre Vista) " ", .. Vista .

, Excel , . , Win7 .

Windows XP Apache, - .

, , - PHP script, . PHP , Apache, script script spawn Excel.

, , , : Excel, . script , Excel, .

0

. , , , .

Excel - , SYSTEM. , , .

Apache .

+3

:

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

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

: -)

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

+2
source

All Articles