Why can't I create a scheduled task with PHP exec()?

391 views Asked by At

I'm having headaches while trying to create scheduled tasks from a PHP script because I only get the same error that my XML code is malformed !

Here's the code I use :

$tn = 'Mailing_19';
$sc = 'ONCE';
$tr = '"\'C:\Program Files\PHP\v5.4\php.exe\' \"D:\inetpub\wwwroot\pdbmanager_fmf\communication\ajax\campagne.publish.php 19 1001\" "';
$st = date('H:i:s', time() + (60*60));
$cmd = 'SCHTASKS /Create /TN ' .$tn .' /SC ' .$sc .' /TR ' .$tr .' /ST ' .$st .' 2>&1';

exec($cmd, $data);
print_r($data);

It ends with : (it's in french, but it means that the XML is malformed):

Array
(
    [0] => Erreur: Le code XML de la tâche contient une valeur incorrectement formatée ou hors limites.
    [1] => (40,4):Task:
)

I don't even know where to find the XML code involved.

This works while trying this in command line though.

Please help !

0

There are 0 answers