Reputation: 1760
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.
Upvotes: 6
Views: 9969
Reputation: 212402
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
Upvotes: 7
Reputation: 4778
You should be able to put the whole thing in quotes fine. I would recommend using php.exe and not just php.
"C:\Program Files (x86)\PHP\php.exe -f c:\inetpub\cron\test.php"
Upvotes: 0