The other product of last night was another win32 only extension, this time for manipulating scheduled tasks. Why do you need an extension? The reason is that Microsoft chose to expose the "mstask" API as non-automation compatible COM APIs; that means that you can't simply use the PHP COM extension (which is really "PHP-OLE") to work with it.
The win32scheduler extension provides 5 functions:
- win32_scheduler_enum_tasks() - returns an array containing the names of the scheduled tasks that are present on the system.
- win32_scheduler_run(string taskname) - requests that the system run a given task immediately. It does not wait for the task to complete.
- win32_scheduler_get_task_info(string taskname) - returns information about a given task.
- win32_scheduler_set_task_info(string taskname, array info [, bool new]) - updates or creates a new task.
- win32_scheduler_delete_task(string taskname) - deletes a named task.
It's fairly self explanatory, although the details for the task info are a little weird. I'll document those for PHP at a later date, but if you're interested in working with it now, you'd do well to read the MSDN docs on the Task Scheduler; the structures and unions docs will help you to figure out the task info format. If you want to create a task, you'll find it helpful to var_dump() the info returned from an existing task; the set_task_info() function uses the same data format. Top tip: you need to supply a "Password" field and set it to the password for the user account you set in "RunAs".
This extension should also be showing up on the PHP 5 PECL snaps page in the next couple of hours.
Enjoy!
"I'll document those for PHP at a later date."
How later is "a later date"?
You can read about it on MSDN, and look at what comes back for existing tasks.
I'm too busy to do it now, otherwise I would have done it already :)
Hi,
any chance to have a similar extension working with php4.3.x?
Thank you :)
If you want a more advanced scheduler to run your php scripts, you should use VisualCron. You can connect to the VisualCron server remotely. http://www.visualcron.com
I' m seriously in need of using win32scheduler extention in php .. how do i set a job of trigger type DAILY ,MONTHLY . etc.
can you please suggest any manuals regarding this topic. I tried MSDN help. but the syntax creates warnings "parameter mismatch error " : 0x80070057
Plz help me out . It' s urgent
