Windows – Launch scheduled task from script

scheduled-taskswindows

On a Windows server, we have a task which runs occasionally, using "Scheduled Tasks" to control it. (best not to run it directly, since it might need to be run as a particular user, and the Scheduled Task configuration has all the appropriate passwords).

We'd like to control this via a PHP script, so that visitors to a website can request the task be run. Can PHP trigger the scheduled task? Including giving an error or taking no action if the task is already running.

Note: lockfiles etc. probably not a useful solution, since the task could fail/crash before completing

Best Answer

An easy way : let your task run all the time but do nothing till it finds some specific file, then delete it and do its job (then go back to wait).

You PHP (or whatever) script just have to create that file ...

Related Topic