3

I have a task to hibernate my computer at 8pm. If I hibernate the computer earlier and turn it on the next morning, the task runs and hibernates the computer (which I don't wont to happen).

I HAVE NOT selected the "Run task as soon as possible after a scheduled start is missed". Shouldn't deselecting that option mean that, if the task is missed, it won't run?

2 Answers 2

0

If you hibernate the computer before the time that the task is scheduled to start then the current clock state is saved as well (for synchronisation purposes).

Once you resume from hibernation, the OS clock is brought back into sync with the hardware clock (which now shows a time and date that is after the scheduled task). I can only think that perhaps this triggers scheduled tasks to run because the time doesn't skip straight from A to B but rather 'plays forward' the interval in-between.

2
  • If this is the problem it might be as simple as setting the task to only run after X minutes of the machine being idle? Just a guess, the task scheduler for me in all versions of Windows never plays nicely. Aug 10, 2010 at 12:02
  • Yes, that could be a solution, but what I really want is the PC to start at 8:45 (this works via the BIOS) and shutdown at 8:00 pm, because sometimes I don't even go to the office but I access the PC remotely. About the hardware clock sync, even so, it should work... probably is a Task scheduler misbehavior. I deleted the task and create a new one, but happens exactly the same. Aug 12, 2010 at 20:24
0

I was having the similar problem. (My task was set to run at 5:30 PM and then wait for 15 minutes of inactivity before suspending.)  In my case, it would work fine so long as the computer was running at 5:30 PM every day. If it ever missed the task due to being suspended, it would run the task on resume (and yes, I had also unchecked "Run task as soon as possible after a scheduled start is missed"). It would then suspend the computer after being resumed and having 15 minutes of inactivity.

So, here's my solution:

  1. Edit your task's trigger. Check "Delay task for up to:" and select "1 minute"
  2. Create a batch file named "kill.bat"

    @echo off
    timeout 10
    schtasks /end /tn TaskName           # (Replace TaskName with the name of your task.)
    

    You may have to tinker with the timeout number. What you're looking for is for some amount of time (in seconds) that falls between a) the time required for the OS's clock to synchronise after resume, and b) the amount of time you delayed your task to run. Setting this number can get squirrelly given that the delay time is a maximum amount and not a specific amount. Try to set this timeout as close as possible to the time needed for the OS's clock to synchronize.

  3. Create a second task – this task will run the batch file you just created upon system resume.

    Trigger:
        Begin the task: "On an event"
        Log: System
        Source: Power-Troubleshooter
        Event ID: 1
    Action:
        Select the batch file you created in step 2.
    

    When configured properly, this new task should run on resume and kill the original task during the 1 minute delay you added to its configuration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .