Page 1 of 1

How to run schtasks from PHP

Posted: Mon Feb 25, 2008 3:00 pm
by repp9418
I am trying to set up Scheduled Tasks through my PHP program. Below is the code I am using.

Code: Select all

   $time = (strlen($_POST['agenttime']) < 5)? '0'.$_POST['agenttime'] : $_POST['agenttime'];
    $command = 'schtasks /create /tn AP_Search_Agent /tr "php -q '.$path.'admin\\run-agent.php" /sc DAILY /st '.$time.':00 /ru "System"';
    $result = shell_exec($command);
when I run the command through the Command Prompt it works. Anyone know why it won't work through a PHP script?

Thanks

Re: How to run schtasks from PHP

Posted: Mon Feb 25, 2008 4:24 pm
by repp9418
I figured it out. The IIS anonymous user needs permissions on schtasks.exe!