I have a file that creates a scheduled task using schtasks:
<?php
$cur_dt = new DateTime('now');
$cur_dt->add(new DateInterval('PT60S'));
$cmd = 'schtasks /create /sc once /ru uname /rp pwd /tn "repost_labor" /tr "' . $fname . '" /st ' . $cur_dt->format('H:i:s') . ' /sd ' . $cur_dt->format('Y/m/d');
exec($cmd, $out, $retval);
?>
so it generates something that looks like this:
schtasks /create /sc once /ru uname /rp pwd /tn "repost_labor" /tr "myfile.bat" /st 12:52:12 /sd 2013/7/23
However, even though it is trying to set the seconds, Task Scheduler ignores it and only adds the hour & minute. So if the current time is 12:51:12, instead of the above creating a task at 12:52:12, it creates it at 12:52:00.
Why does Task Scheduler ignore the seconds?
Is there a workaround?
Thanks!
<?php
$cur_dt = new DateTime('now');
$cur_dt->add(new DateInterval('PT60S'));
$cmd = 'schtasks /create /sc once /ru uname /rp pwd /tn "repost_labor" /tr "' . $fname . '" /st ' . $cur_dt->format('H:i:s') . ' /sd ' . $cur_dt->format('Y/m/d');
exec($cmd, $out, $retval);
?>
so it generates something that looks like this:
schtasks /create /sc once /ru uname /rp pwd /tn "repost_labor" /tr "myfile.bat" /st 12:52:12 /sd 2013/7/23
However, even though it is trying to set the seconds, Task Scheduler ignores it and only adds the hour & minute. So if the current time is 12:51:12, instead of the above creating a task at 12:52:12, it creates it at 12:52:00.
Why does Task Scheduler ignore the seconds?
Is there a workaround?
Thanks!