0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.