Oh yeah, I may have missed out on a few things.
The code essentially doesn't work. I've tried variations of it running on a localhost xampp configuration. When I load the localhost webpage it doesn't show my task on the task list.
The task, "mytask" is nowhere to be found when I run the php file. I know the command is correct because it works via, custom batch file but I need the command to run from a php script. The name of the task will be manipulated in the future.
Ive tried running another simple configuration in order to prove whether php was capable of running batch commands.
shell_exec('mkdir testdir');
So simple commands such as creating a directory works with php shell_exec. But I cant get it to create a cron job using the Windows Task Scheduler.