0

I have a task set up to wake the computer from sleep at a specified time each day. Windows 10 Task scheduler is set to run a .bat file (“echo hello”) as admin with the “wake computer to run task” condition enabled. If I put the computer to sleep via the power menu, I get different results depending on which computer I am running it on.

On a Dell Optiplex 960, Bios A18, the task causes the light on the tower to stop flashing and the keyboard to light up, but the screen doesn’t not come back on. I’ve tried it with a sound file and there is no audio, but on manual wake via the keyboard, media player is open and the file appears to have played.

On a Biostar N68s3+, nothing happens and Task Scheduler says “The operator or administrator refused the request.”

On a Ryzen 5xx, it works perfectly.

I’ve turned on every power and wake function I can find in Windows and the bios. Does this have something to do with the older boxes not technically supporting windows 10? Is there a feature I should be looking for on new boards? I’ve spent hours on this and it’s driving me nuts. Unless there’s a much better tool to do this, I’d like to stick with Task Scheduler to prevent resource load and because it will be a lot of on/off events throughout the day. My arcade thanks you in advance.

Following these instructions: https://www.groovypost.com/howto/schedule-wake-sleep-windows-automatically/

Sleep.xml:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2021-08-19T10:40:52.0677749</Date>
    <Author>RIKER\Admin</Author>
    <URI>\Sleep</URI>
  </RegistrationInfo>
  <Triggers>
    <TimeTrigger>
      <StartBoundary>2021-08-23T14:30:00</StartBoundary>
      <Enabled>true</Enabled>
    </TimeTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1800914523-2772139078-3296455877-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</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>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\BAT files\sleep.bat"</Command>
    </Exec>
  </Actions>
</Task>

Sleep.bat: Rundll32.exe Powrprof.dll,SetSuspendState sleep

Wake.xml:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2021-08-19T10:41:17.49175</Date>
    <Author>RIKER\Admin</Author>
    <URI>\Wake</URI>
  </RegistrationInfo>
  <Triggers>
    <TimeTrigger>
      <StartBoundary>2021-08-23T14:35:00</StartBoundary>
      <Enabled>true</Enabled>
    </TimeTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1800914523-2772139078-3296455877-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</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>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\BAT files\wake.bat"</Command>
    </Exec>
  </Actions>
</Task>

Wake.bat: echo hello

I've done so many combinations of tests on 5 machines, so I'm starting to get confused.

The sleep task always works. The put to sleep via the sleep task, the wake task works inconsistently between machines, waking some of them (but not the screen) and not waking others (including a Ryzen 5). The ones that do wake seem to go back to sleep a minute later.

When put to sleep via the start menu, the wake task wakes the two newer machines (screen included), and wakes two other machines (but not the screen). None of those machines go back to sleep a minute later.

One machine didn't wake regardless of if it was a sleep task or start menu sleep.

When using KM Wakeup, all machines sleep and wake properly, screens included.

Hibernate is off (powercfg -h off), wake timers are enabled on all power modes. I've updated bios and chipset firmware, and checked bios power/alarm options.

My next step is to try this as maybe there is an issue with Rundll32.exe: Task Scheduler won't wake the computer

1
  • How are you connecting the screen on the Dell? If it is by DisplayPort you can sometimes run into issues where DisplayPort turns off entirely and you either need to unplug the cable or reboot the machine to get the screen to come on again.
    – Burgi
    Commented Aug 27, 2021 at 11:18

1 Answer 1

0
  1. Was "Allow wake timers" present in advanced power settings in each of the computers you tried ? If not, then the computer doesn't support them at all. You may also try this

  2. In your tests, put the computer to sleep at least 1 min before trigger time. (1 min is based on my laptop Acer Aspire). Else, if the interval after sleep start is too short, then that task does wake the computer (within secs..<1min of the trigger) but just doesn't manage to launch and to run.

  3. About screen not turning on: the help pages of Task Scheduler say that

When the Task Scheduler service wakes, the computer to run a task, the screen may remain off even though the computer is no longer in the sleep or hibernate mode. The screen will turn on when Windows detects that a user has returned to use the computer.

So, it's system dependent. If after putting computer to sleep VIA POWER MENU, the task wakes it, and you can tell that the task ran (ex, add to the bat file a echo hello %time% C:\your\path\to\test.txt ) but the screen doesn't turn on, for whatever reason, then probably for the same reason it does not turn on the audio when playing a sound file.

  1. I would disable, at least for testing, the "hybrid " sleep in power options \change plan settings\ change advanced power settings \ Sleep \Allow hybrid sleep. It's intermediate between sleep and hibernation.

  2. Definitely can be an issue with the command in sleep.bat . Even if this trick (disabling hybernation then running that command) works on some computers (including mine), it is not guaranteed, it is advised against as it corrupts the stack, as others have pointed out, see in numerous comments at: How can I put the computer to sleep from Command Prompt/Run menu?, and actually should not work https://answers.microsoft.com/en-us/windows/forum/windows_10-power/anyone-know-a-batchscriptprogramexe-that-can-put/741c42d6-41a4-47b2-9c64-fddbf1605637

  3. If you need to make it sleep with a command, I think your best bet is following the steps in the last link above:

Download Sysinternals PsTools.
The download should be a ZIP file.
Open it and copy PsShutdown.exe to your desktop.
On your desktop, right-click PsShutdown.exe and click Copy. Right-click it again and click Properties. Tick Unblock and click [OK].
Open File Explorer, navigate to "C:\Windows", scroll down, right-click the system32 folder and click Paste.
To enter standby, you can now use this command:
psshutdown -d -t 0

(tested on my laptop too).

3
  • Followed your instructions. Posted XMLs, bat files, and test results in my edit. Commented Aug 23, 2021 at 21:20
  • @KyleHarvey I've added # 3 (last half) and #4 to #6 in my answer. Hope it helps at least for most of your computers.
    – Victor
    Commented Aug 26, 2021 at 2:20
  • @KyleHarvey p.s. I did look at the posted XMLs and bats, and ran them on my computer (running win7 though), and as far as I can tell, nothing wrong with them (apart from the command to put to sleep, as I wrote about).
    – Victor
    Commented Aug 26, 2021 at 3:53

You must log in to answer this question.

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