Executing PHP file with Windows server 2008 Scheduled Task

cron, php, scheduled-tasks, windows-server-2008

Solution

If the path contains spaces, then wrap it in quotes

"C:\Path\to\php.exe" -f "C:\Path\to\file.php"

the same way you do with the file to execute

Problem

i know there are a lot of posts about scheduled task and a fair few about executing PHP files but i have looked and tried to figure it out but still coming up short. I am still learning a lot of the ways of Windows server so please, if something needs to be pointed out let me know. So i set up a scheduled task that would execute at 1am and in all fairness this worked a charm, however i didn't realise that it would just open the file in notepad (Because that is the application that php files are associated with). So i did my research and found a lot people saying that i needed to pass the php.exe file in with it, these people were also providing i add this to the task: ``` C:\Path\to\php.exe -f "C:\Path\to\file.php" ``` So i put it in the action tab like so. please note that there is an error in the screen shot, i forgot to put \php.exe at the end of the sting. When i click OK i get asked this As you can see from the picture it only lists "C:\Program" I've tried moving things around and had nothing, i've tried wrapping the first part in quotes as well. So can someone tell me what i need to do or what i'm doing wrong here? Thanks for your time.

Original source