Installing PHP
You don't have to install xammp
, you can install PHP alone, have a look ate the windows PHP installation guide:
If you prefer installing XAMP, you can run PHP script after locating the php.exe
with the -f
flag:
C:\Xampp\php\php.exe -f C:\Xampp\htdocs\my_script.php
Running the PHP file
After you have PHP installed, check Command Line PHP on Microsoft Windows manual for information on how to run the script. On the page there is explanation of how to make the php file executable, so you could run it as:
"C:\PHP Scripts\script" -arg1 -arg2 -arg3
Make sure you are using an administrative account to run the command. Otherwise you might have permissions problems. more info at the Introduction to using PHP on the command line
Scheduling the task
Go to Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks
,
- Right-click on an empty spot in the Scheduled Task window and select New -> Scheduled Task (Also accessible via File -> New -> Scheduled Task)
- Name the new task (How about "Bill"? He looks like a Bill, doesn't he? "Mr. B. Evolution, II" It sounds so regal.)
- Double-click the new task to open the properties window (or File -> Properties)
- Under the Task tab, enter the same command that you used to test the script above. For instance, I would enter:
C:\PHP\php.exe "C:\Inetpub\wwwroot\blogs\cron\cron_exec.php"
- Go to the Schedule tab and enter when and how often the task should run. The schedule defaults to run once daily and should be fine for basic usage, but feel free to tweak as needed.
- The rest of the fields can be left as-is, unless you're an ace and know what you're doing.
- Click OK and we're done!
for more info have a look at
setting up a window scheduled task.