I have installed localhost/server in my machine and I need to run a php script using windows schedule task. how do I add path in \"Actions\" tab in schedule task / cofigure
If the answer given by Pekka does not work (C:\Xampp\php\php.exe -f C:\Xampp\htdocs\my_script.php
), make sure that you have the correct PHP extensions enabled as well as the correct php.ini
file being used for the PHP version you are using.
I ran into this issue recently and resolved it. I was using PHP v5.4 to run my script.php that was nested within the top level PHP folder (v5.3). When I ran the script.php
, from within the v5.4 folder, it was using the v5.3 php.ini
file with different extensions, which caused the script.php
to fail.
To fix this, here is what I did within the Task Scheduler : Actions tab
Program Script:
"C:\Program Files (x86)\PHP\v5.4\php.exe"
Add Arguements:
-c "C:\Program Files (x86)\PHP\v5.4\php.ini" -f "C:\Xampp\htdocs\script.php"
Using the -c
option, you can specify which php.ini
file should be used (stackflow answer).
I verified which php was in use by following this stackflow answer.
In command line, type php -m
to check which extensions are enabled.
Then, use php --ini
to check which .ini
file(s) is/are being read by PHP.
You may not be using the correct ini file for the PHP version you are using if you have multiple versions installed.