Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

05 Dec 2015   #1
AndreyT

Windows 7 Pro x64
 
 
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 System SpecsSystem Spec
.
06 Dec 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
06 Dec 2015   #3
torchwood

W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
 
 

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

Roy
My System SpecsSystem Spec
.

06 Dec 2015   #4
AndreyT

Windows 7 Pro x64
 
 

Quote   Quote: Originally Posted by torchwood View Post
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 System SpecsSystem Spec
06 Dec 2015   #5
torchwood

W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
 
 

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 System SpecsSystem Spec
06 Dec 2015   #6
AndreyT

Windows 7 Pro x64
 
 

Quote   Quote: Originally Posted by torchwood View Post
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 System SpecsSystem Spec
06 Dec 2015   #7
Brds7t7

Windows 7 Pro 64-Bit, Windows 7 Ultimate 64-Bit, Windows 8.1 Pro 64-Bit
 
 

Quote   Quote: Originally Posted by torchwood View Post
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 System SpecsSystem Spec
06 Dec 2015   #8
DavidE

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
 
 

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 System SpecsSystem Spec
07 Dec 2015   #9
AndreyT

Windows 7 Pro x64
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
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 System SpecsSystem Spec
10 Dec 2015   #10
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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.


Attached Files
File Type: zip Sleep at 9am.zip (1.0 KB, 1 views)
My System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Task Scheduler not running??
Hello- Anyone getting this message or had it and corrected it? see attachment. I''ve been on Google for a loong time and not really finding a fix. HP system 3 weeks old and this seems to be a problem for a ton of people. I check the services and its running and grayed out so I can't touch...
Performance & Maintenance
Task scheduler not running??????
My daughter has an HP laptop that she uses in nursing school. It started acting funny and I found a bunch of junk on the computer that she says she doesn't know where it came from. But me problem is that automatic updates has stopped working along with the disk defag. When I try to run the...
General Discussion
Task Scheduler not Running Tasks
I created two tasks (Utorrent and Flashget) to run at 12:15 am every night but the tasks refuse to startup. I usually hibernate my computer at night so i have the two tasks "wake computer up to run this task" (the computer does wake itself up) The only way i can get it to run is if i manually run...
General Discussion
Task scheduler unable to load task status/active tasks at startup.
My task manager is unable to load task status/active tasks at startup. I get the message: "The selected task "{0}" no longer exists. To see the current tasks, click Refresh." When I refresh I get the same message. I checked and found that under Microsoft the problem was in the defrag...
Performance & Maintenance
Task Scheduler not running
I can't install anything on my computer or run disk defragger because I keep getting error messages. Here is one: "Disk Deragmenter cannot start because the task scheduler service is not running. Start the task scheduler service and try again. I tried to mess around with the task scheduler...
General Discussion
task scheduler not running missed task
When i set task scheduler to run a program it works. But if the pc is not on at the time it will not run unless task scheduler is opened. It is set to run as soon as poss after scheduled time and task scheduler itself starts and runs properly
General Discussion


Our Sites

Site Links

About Us

Find 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 14:01.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App