How to prevernt Task Scheduler from running overdue actions on resume


  1. Posts : 22
    Windows 7 Home Premium 64bit.
       #1

    Prevent Task Scheduler from running overdue actions upon resume


    With the Task Scheduler, I've created a task to hibernate at 7pm. (Action: shutdown -h). It works fine.

    However problem occurs if I manually hibernate earlier. Upon turning on the computer the next day, the computer resumes, then hibernates immediately!

    I can't find any setting to prevent that from happening. Can someone help?
    Last edited by KumaraB; 19 Jul 2014 at 04:13. Reason: correct typo in title and make it clearer
      My Computer


  2. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #2

    KumaraB said:
    With the Task Scheduler, I've created a task to hibernate at 7pm. (Action: shutdown -h). It works fine.

    However problem occurs if I manually hibernate earlier. Upon turning on the computer the next day, the computer resumes, then hibernates immediately!

    I can't find any setting to prevent that from happening. Can someone help?
    Task Scheduler has a setting that should do exactly that, reset task if the scheduled time is missed, but as much as I have tried I have never get it to work.

    In task settings you can find a setting Run task as soon as possible after a scheduled start is missed:

    How to prevernt Task Scheduler from running overdue actions on resume-2014-07-18_12h09_20.png

    Disabling it should do exactly what you want to, it should "reset" the task when the scheduled time is missed and only run it again at the next scheduled time. However, I have tried to get this working in a certain task, have had no luck; it seems this setting is totally ignored by Task Scheduler (at least in Windows 8.1 I'm using).

    However, you could use an easy workaround. Do this:
    1. Allow task to be run on demand:
      How to prevernt Task Scheduler from running overdue actions on resume-2014-07-18_12h09_21.png
    2. Create a new shortcut to your desktop to run this command (replace Hibernate with the name of your task):
      Code:
      schtasks.exe /run /TN Hibernate

    That's it. Now when you want to hibernate before the scheduled time do it by double clicking the shortcut you created instead of selecting Hibernate from Start Menu. The PC hibernates and task is marked to be run, your PC does no longer hibernate immediately when waked up after the scheduled time.

    Kari
      My Computer


  3. Posts : 22
    Windows 7 Home Premium 64bit.
    Thread Starter
       #3

    That's so very smart. Kiitos paljon!

    Anyway, I did try the same thing you expected by disabling that setting. Wonder if MS would issue an update to correct that bug if we report it?
      My Computer


  4. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #4

    You are welcome :).

    To run a task from command line is quite practical workaround, I use it myself always if a scheduled task needs sometimes to be run on demand. If you do it quite often then a shortcut which will run the task will do the trick.
      My Computer


  5. Posts : 22
    Windows 7 Home Premium 64bit.
    Thread Starter
       #5

    This worked. Then, for some unknown reason, the problem returned!

    Perhaps it's because I meddled with something. I don't get it. Any ideas?
      My Computer


  6. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #6

    KumaraB said:
    This worked. Then, for some unknown reason, the problem returned!

    Perhaps it's because I meddled with something. I don't get it. Any ideas?
    I really cannot understand what you mean with this? The workaround I told you in post #2 is always valid, works always.

    Here's the workaround explained:
    1. When computer is shutdown or hibernated before your hibernation task is scheduled to run, and computer is again turned on or waked up first after this scheduled time, the task which has missed its scheduled time will run as soon as it can, meaning your computer will hibernate as soon as it has been turned on or waked up
    2. To avoid this you simply create a shortcut for your hibernation task and allow the task to be run on demand
    3. Now when you want to hibernate before your scheduled hibernation task is supposed to be run, you do it from the shortcut
    4. This marks the task to be run and it is no longer run when you power on or wake up the computer

    It really is this simple, I cannot see how you could meddle with it?

    Kari
      My Computer


  7. Posts : 22
    Windows 7 Home Premium 64bit.
    Thread Starter
       #7

    Firstly, thanks for the response, Kari. I understand your explanation, I just didn't understand why Windows didn't do as expected. A possible good news is though is I now realise why it might have failed: I had the command line placed in a batch file because I wanted to run something before hibernation. Shall test just the shortcut and revert.
      My Computer


  8. Posts : 22
    Windows 7 Home Premium 64bit.
    Thread Starter
       #8

    I confirm that using purely the shortcut works. I suppose what I did was wrong because the batch file works within a command shell, thus a separate process. Now, to fulfil my preference, I have the task action set as the batch file instead. Should be okay now. Thanks.
      My Computer


  9. Posts : 22
    Windows 7 Home Premium 64bit.
    Thread Starter
       #9

    Just like to add that what I want, i.e. run a batch file where various processes are run before hibernation, is a bit more complicated. To cut the story short, here's what works:
    1. Create a batch file which includes various processes including shutdown -h, and put it wherever you want. (I name it "Execute Hibernation Sequence.bat".)
    2. Create scheduled task (with the triggers you want) pointing to that batch file. (I name it "Execute Hibernation Sequence".)
    3. On the desktop, create a shortcut for the scheduled task: schtasks.exe /run /TN "Execute Hibernation Sequence". (You need to name the last part according to the name you give the scheduled task.)
    Last edited by KumaraB; 21 Aug 2014 at 01:12. Reason: Correction
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:28.
Find Us