Task Scheduler: running skipped task when it shouldn't?

Page 1 of 2 12 LastLast

  1. Posts : 14
    Windows 7 Pro x64
       #1

    Task Scheduler: running skipped task when it shouldn't?


    I have a secondary computer in the network, which is supposed to stay in sleep mode most of the time. I always wake it up when necessary and put it back to sleep when it is no longer needed. I don't want it to fall asleep by itself during the day, so I set the sleep time to "Never" in Power Settings. However, I want it to automatically fall asleep at 9PM (if at the time it is not sleeping already).

    So, in order to satisfy these requirements I created a .bat file containing the following line

    Code:
    %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby
    and I added that .bat file to Task Scheduler, asking it to run it every evening at 9PM. I made sure that "Wake the computer to run this task" flag is cleared. I also made sure that "Run task as soon as possible after a scheduled start is missed" flag is also cleared.

    However, the next morning when I come to that computer and wake it up for the first time, it wakes up and then immediately falls asleep again. Then I wake it up again and it stays on. Looking into the Task Scheduler reveals that Task Scheduler actually decides to run this task immediately after I wake up the computer, thus putting it back to sleep.

    Why does this happen? I believe my set of settings is telling Task Scheduler not to try to run this task if the original scheduled time (9PM) is missed. Why then does it attempt to run it when I wake the computer the next morning? What else do I need to specify to make Task Scheduler to quietly ignore missed attempts to run this task?
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hey there AndreyT,

    It isn't immediately obvious to what the problem could be. It would help if we could see all the configurations of this task you've made, allowing us to create a similar task ourselves and report back a possible solution.

    Would you care to open a PowerShell session and enter the lines below in sequence,
    Code:
    $TskSch = New-Object -ComObject Schedule.Service;
    $TskSch.Connect()
    $TskSch.GetFolder('\').GetTasks(1) | ?{$_.Name -match 'taskname'}
    substituting taskname with the name of the task in question, and censoring any information you don't wish to reveal. Post the command's output here.
      My Computer


  3. Posts : 7,107
    W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
       #3

    Why not set it to hibernate then perform the sleep operation as and when required.

    Roy
      My Computer


  4. Posts : 14
    Windows 7 Pro x64
    Thread Starter
       #4

    torchwood said:
    Why not set it to hibernate then perform the sleep operation as and when required.
    Well, firstly, I don't see why I would want to consider Hibernate. I don't see any purpose in Hibernate besides being a "last resort" measure for sleeping battery-powered laptops that are about to run out of battery. (In fact, this is really what Hibernate is for.) In my case it is a desktop system constantly connected to AC power. So I use Sleep as a natural way to quickly "suspend"/"unsuspend" the system. Hibernate would simply make the whole thing a lot slower, which I do not want to tolerate.

    Secondly, is there any reason you think that Hibernate will behave differently in the context of the question? Meaning, a Task Scheduler-initiated Hibernate won't force the computer back to sleep when I wake it up next morning?
      My Computer


  5. Posts : 7,107
    W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
       #5

    Hibernate is a >>>faster<<< start up than sleep, its not purely for battery saving.
    secondly it would remove any conflict in your Bat file operation, which uses the sleep option.

    Roy
      My Computer


  6. Posts : 14
    Windows 7 Pro x64
    Thread Starter
       #6

    torchwood said:
    Hibernate is a >>>faster<<< start up than sleep, its not purely for battery saving.
    secondly it would remove any conflict in your Bat file operation, which uses the sleep option.
    Er... What? No. Startup from Hibernate is significantly slower than startup than Sleep. And "significantly" means an order of magnitude slower. It is not even remotely comparable.

    Startup from Sleep is almost instant. Startup from Hibernate requres a full-blown regular power up and boot sequence.

    Which is, again, why Hibernate is normally excluded from the menus by default. It has no uses aside from what I mentioned before.

    That is unless you are talking about some unorthodox Hibernate.
      My Computer


  7. Posts : 1,797
    Win 7 Ultimate, Win 8.1 Pro, Linux Mint 19 Cinnamon (All 64-Bit)
       #7

    torchwood said:
    Hibernate is a >>>faster<<< start up than sleep, its not purely for battery saving.
    secondly it would remove any conflict in your Bat file operation, which uses the sleep option.

    Roy
    Roy, are you confusing hibernate with hybrid sleep?
    Hibernate does take longer to power up than hybrid sleep.
    Hybrid is almost instant and opens the logon screen straight away. Hibernate has to power up past the BIOS and post screen as it's the lowest power state.

    Hibernate is designed more for laptops to save battery, although it can be used on desktops too.
      My Computer


  8. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #8

    Hybrid sleep does a Sleep and Hibernate when the PC Sleeps.
    - It saves the current Windows session in RAM for Sleep/Wakeup.
    - It also saves the current Windows session in the hiberfil.sys file for Hibernate/Resume.

    With Hybrid sleep:
    - If the power goes out when the PC is Sleeping it can't wake from sleep, the Windows session in RAM is "lost".
    - It will resume from hibernate.

    I have desktops and use Hybrid sleep.
    I've been using Hybrid Sleep since 2009 for W7, W8.x, and W10, and it works reliably for me.
    There are various reasons i depend on hybrid sleep/hibernate such as:
    Power goes out when the PC is sleeping, nearby electrical storms and i want to disconnect the power, i need to reset my KVM.

    Startup for me:
    - Wake from Sleep is fastest
    - Resume from Hibernate is slower, if i did a manual hibernate
    - Resume from hibernate is MUCH slower if i did a Sleep, power went out, and it resumed from hibernate using the hybrid sleep option

    In all cases, it restores my Windows session correctly, with all programs/data working as i last used them.
      My Computer


  9. Posts : 14
    Windows 7 Pro x64
    Thread Starter
       #9

    Pyprohly said:
    Post the command's output here.
    This is what I got from running the command sequence. (Note that `LastRunTime` is reported as `9:50:13 AM`, which is from my attempt to wake up the computer this morning.)

    Code:
    Name               : Sleep at 9pm
    Path               : \Sleep at 9pm
    State              : 3
    Enabled            : True
    LastRunTime        : 12/7/2015 9:50:13 AM
    LastTaskResult     : 0
    NumberOfMissedRuns : 0
    NextRunTime        : 12/7/2015 9:00:00 PM
    Definition         : System.__ComObject
    Xml                : <?xml version="1.0" encoding="UTF-16"?>
                         <Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
                           <RegistrationInfo>
                             <Date>2015-12-01T17:02:11.6578378</Date>
                             <Author>STAMP\andreyt</Author>
                           </RegistrationInfo>
                           <Triggers>
                             <CalendarTrigger>
                               <StartBoundary>2015-12-01T21:00:00</StartBoundary>
                               <Enabled>true</Enabled>
                               <ScheduleByDay>
                                 <DaysInterval>1</DaysInterval>
                               </ScheduleByDay>
                             </CalendarTrigger>
                           </Triggers>
                           <Principals>
                             <Principal id="Author">
                               <RunLevel>LeastPrivilege</RunLevel>
                               <UserId>STAMP\andreyt</UserId>
                               <LogonType>InteractiveToken</LogonType>
                             </Principal>
                           </Principals>
                           <Settings>
                             <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
                             <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
                             <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
                             <AllowHardTerminate>true</AllowHardTerminate>
                             <StartWhenAvailable>false</StartWhenAvailable>
                             <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
                             <IdleSettings>
                               <StopOnIdleEnd>true</StopOnIdleEnd>
                               <RestartOnIdle>false</RestartOnIdle>
                             </IdleSettings>
                             <AllowStartOnDemand>true</AllowStartOnDemand>
                             <Enabled>true</Enabled>
                             <Hidden>false</Hidden>
                             <RunOnlyIfIdle>false</RunOnlyIfIdle>
                             <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
                             <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
                             <WakeToRun>false</WakeToRun>
                             <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
                             <Priority>7</Priority>
                           </Settings>
                           <Actions Context="Author">
                             <Exec>
                               <Command>C:\Utils\sleep.bat</Command>
                             </Exec>
                           </Actions>
                         </Task>
      My Computer


  10. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #10

    AndreyT, I created a task similar to that of the task specifications you've posted, though I was unable to replicate the issue you describe; the task I made seemed to work just fine. I was, however, testing the task out with a Windows 8.1 laptop machine, so I didn't bother going too in-depth with this (as I believe the sleep and hibernate functions work slightly differently between desktops and laptops)...

    Perhaps someone else with a machine setup closer to yours can confirm if the attached task behaves well, i.e., the task doesn't run upon turning the computer on after the trigger time (9am) has passed.
    Task Scheduler: running skipped task when it shouldn't? Attached Files
    Last edited by Pyprohly; 20 Dec 2015 at 22:01.
      My Computer


 
Page 1 of 2 12 LastLast

  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 17:21.
Find Us