Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing PHP file with Windows server 2008 Scheduled Task

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. Screen shot of New task widnow

When i click OK i get asked this

Screen shot after clicking OK

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.

like image 307
ragebunny Avatar asked Apr 04 '13 09:04

ragebunny


1 Answers

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

like image 95
Mark Baker Avatar answered Nov 05 '22 03:11

Mark Baker