views:

138

answers:

1

I thought I had set up a successful schedule in Windows to run a PHP script. But all I got was an error which slaps only when run through the task scheduler.

Here is how I run the task:

I created a batch file runCron.bat:

start php.exe reportGenerator.php

and placed reportGenerator.php in the same folder as of the batch file.

When I manually execute the batch file, all is well. But when the same batch file is called by the task scheduler, PHP CLI throws the following error:

Could not open input file: reportGenerator.php

What would have been missed? I understand it's a path issue, but where exactly is the issue?

Thank you for any help.

+1  A: 

try

 start php.exe -f c:\full\path\to\reportGenerator.php

it probably looks for the script in the schedulers working directory, not in the bat file dir

stereofrog
That solved the problem. Thank you. Since the batch file is calling php, I thought it should be taking its path as base. Now I understand that the first-caller always takes control of the path.
Nirmal