为什么我不能使用PHP exec()创建计划任务?

时间:2015-06-10 14:24:33

标签: php scheduled-tasks schtasks.exe

我在尝试从PHP脚本创建计划任务时遇到了麻烦,因为我只得到与我的XML代码格式错误相同的错误!

这是我使用的代码:

$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);

它以:(它是法语,但这意味着XML格式不正确):

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

我甚至不知道在哪里可以找到所涉及的XML代码。

虽然在命令行中尝试此操作时可以正常工作。

请帮忙!

0 个答案:

没有答案
相关问题