0

I have a program I'm attempting to transfer over to a server to run with a scheduled task. It's using PHPExcel to essentially automate a schedule. In order to run it I created a batch file like I have for other reports I've done as scheduled tasks. That is simply with this code:

php C:\wamp\www\Folder\File.php
pause

Now when I run this as the batch file manually, everything works perfectly and there's no problems. If I run it through task scheduler whether manually or scheduled, it can't find the first of the parameter tables it needs to open to find pertinent information and ends there with this exception: Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open ExcelFile.xlsx for reading! File does not exist.'

Some research has shown similar problems being caused by privileges, excel having problems with automation, the code from the batch file, and having the wrong path.

Privileges shouldn't be an issue because I'm running it from the domain administrator account, though I wonder if since it's a virtual machine that was just set up in a hurry perhaps there's something off. It just doesn't make sense for a user-level account to have more privileges than system level considering both are admin.

It's currently running with libreoffice, which I thought might be the issue except as previously mentioned it runs fine when manually running the batch file. And that throws the excel issues out.

Those other two issues were pretty easy to check, simply because it runs correctly one way, and if they were off it would never run correctly.

Are there any ideas why this would be occurring like this and how to fix it? How can it run fine manually on an admin user account, but not automatically as a system level task running with admin level privileges?

Thank you

bmac
  • 69
  • 8
  • 1
    Might need to set working directory for your script... see: http://stackoverflow.com/questions/5254000/php-how-to-set-current-working-directory-to-be-same-as-directory-executing-the – ficuscr May 15 '15 at 19:39
  • Yup, that was exactly it. Thanks, and now I'll never not check that again... Still learning! – bmac May 15 '15 at 19:49

0 Answers0