I need to perform the scheduling of sending an email dynamically on a windows server running IIS. I have the following code in PHP:
class AgendarTarefaWindow{
public function agendar($nome, $data, $tarefa){
$array = explode(' ',$data);
$comando = 'SCHTASKS /Create /SC ONCE /TN '.$nome.' /TR "'.$tarefa.'" /ST '.$array[1].' /SD '.$array[0].' /F ';
$dados = system($comando,$resultado);
var_dump($dados, $resultado, $comando);
}
public function excluirAgendamento($tarefa){
exec('schtasks /Delete /TN '.$tarefa.' /F');
}
}
$agenda = new AgendarTarefaWindow();
$agenda->agendar('ncccTeste', date('d/m/Y H:i:s',strtotime( "+2 minute",strtotime(date('Y-m-d H:i:s')))), 'php -f C:\inetpub\wwwroot\ClickFood\obj.php');
If I call it via the command line: php -f enderecoFile it works perfectly. When I call it through the browser, the script simply does not work.
If anyone knows what it can be I am very grateful.
The result of var_dump () is the following:
string(0) ""
int(-2147467259)
string(121) "SCHTASKS /Create /SC ONCE /TN ncccTeste /TR "php -f C:\inetpub\wwwroot\ClickFood\obj.php" /ST 14:30:00 /SD 23/07/2015 /F "