Windows tasks do not invoke includes when they run a php page?

I do most of my development work in windows so I emulate cron jobs with windows task scheduler. But when I run a task it does not successfully include the includes in the php file, so I can’t use my database connection includes. I have been building the necessary includes into the scripts but that is pretty annoying and time consuming.

task scheduler is set to run a .bat file named scheduled-task.bat which contains:

“cmd /K C:\wamp\bin\php\php5.3.8\php.exe -f C:\wamp\www\site\cron.php” (no quotes)

Any idea on how to fix this so my included files are actually included?

I understand that PHP cli uses a different php.ini – though how that works on win32 I am not sure.

Why dont you output phpinfo() from one of these scripts, pick up the output and check what it says for a) the include_path b) the ini file address.

Failing that, try and put a test include in the same folder and see if that gets get picked up …

It has nothing to do with Task Schedular. Its probably as simple as “PATH NOT FOUND” for you includes. Understand, command line has completely different pathing then a server. Unless you are careful using full absolute paths are set the current worrking directory, paths will be different.

You could drop the batch file and let Task Scheduler direct access…

“Start in” is like “CD some/path” in the command line.

You were right; I didn’t specify an absolute path. I tried writing an includes using an absolute path and it worked.Thanks. This may make emulation of a cron job a bit harder though, I think, since the includes on my dev machine and the includes on the server will be different, and I will have to replace them.

Use DIR (PHP 5.3+) or direname(FILE) to get paths relative to the location of your file.