Search code examples
phpwindows-task-scheduler

Run php file w/ Windows Task Scheduler


I need to execute some php scripts using the Windows Task Scheduler, I've found some similar questions but none got me to the right answer.

The script basically automatically sends emails or store them in a database if the smtp fails, which means that I'm using classes that aren't in my script (using require "myclass.php"). So my first question : is this possible or do I have to set up every class in the same php file ?

I've set up my task like this:

C:\wamp\bin\php\php5.6.31\php.exe -f "C:\wamp\www\myproject\myscript.php"

Second question : Does it need an administrator account to execute this line ? Since launching wamp need one, I was thinking maybe php.exe needs it too.

I'm trying (if possible) to avoid using a batch file like suggested here (where the .bat is executed by the task scheduler).


Solution

  • The problem is that all the classes called in the script HAVE to be in the same php file, require("myclass.php") does not work.