4

In Win 10 Pro, I have used task scheduler to make my PC go to sleep (not hibernate) at night, which works fine. But I am trying to get my PC to wake itself up in the morning, but no luck here. I have enabled wake timers in the Windows Power Options, and selected "wake this computer" in task scheduler options.

1

2 Answers 2

3

Make PC wake up using task scheduler in Win 10 from sleep

I am trying to get my PC to wake itself up in the morning, but no luck here. I have enabled wake timers in the Windows Power Options, and selected "wake this computer" in task scheduler options.

Two Steps

Step 1

Create a batch script (example in solution part two below) that emulates keyboard key strokes. Schedule it with Windows Task Scheduler and tell it to wake up the computer to run the task at the designated time(s).

(Again, example batch script at bottom to use for scheduling along with logic native to Windows that emulates keyboard strokes (SendKeys) which will wake up the sleeping monitor.)

SOURCE: How to Make Your PC Wake From Sleep Automatically - Further Detail

enter image description here


Step 2

Use the below batch script logic to natively emulate keyboard key strokes with a dynamically built and executed VBS script with batch though. This will be the batch script to execute logic-wise as an example.

Example batch script sending space multiple times like pressing the spacebar

(You can use any other keys you need to with SendKeys as well)

@ECHO OFF
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs

:VBSDynamicBuild
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"

CSCRIPT //nologo "%TempVBSFile%"
GOTO EOF

Trouble with Computer waking up from Sleep

If you've had trouble with Windows Scheduled Tasks waking up your computer when it is sleeping, then you may want to disable hibernation in case that's the cause. To do this just open Windows command prompt as administrator, type in this command POWERCFG HIBERNATE OFF, press Enter, and then restart the PC. Also see POWERCFG for more detail of this command.

Test It

If possible, you may want to test to confirm that this fixes the issue. Setup the job as specified below but set it to kick off in 2-5 minutes from the time you're ready to test. When you're ready, run this from command line (as administrator again) to put the Windows 10 machine to sleep C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState 0,1,0, and then just wait to see if that works.

Still Not Working

See my accepted answer here in this post related to Scheduled Task Problems. While this answer is for Windows 7, these options still apply to the Task Scheduler on Windows 10 so just look through it and ensure the options are set as indicated or where applicable and equivalent.


3
  • Thank you for the answer, much appreciated. But can I please ask, will the above solution 1) wake up the PC first, and then 2) run the batch script? If yes,, I'm not sure it will work. I have currently set the task scheduler to wake the pc up in the morning and run cmd.exe, executing the instruction "exit". But that doesn't work, because the PC doesn't wakeup tself in the morning first. Before it can run cmd.exe.
    – Bhup
    Commented Jan 3, 2016 at 17:50
  • @Bhup I just added an updated section to the bottom of my answer with additional items to potentially help resolve this issue if it still exists. You should be able to test and confirm this as indicated in the Test It section. Commented Jan 4, 2016 at 22:04
  • Why the large script? You could just run cmd.exe with the parameter /c "exit" or someting similar?
    – Squazz
    Commented Feb 20, 2017 at 21:23
-1

Working Solution!
I had to use the PsShutdown utility to allow proper sleeping (primary issue is SetSuspendState does not allow wake timers to wake up the machine). My batch file to sleep is 1 simple line: PsShutdown -d -t 2

My whole setup is: scheduled task runs a VBS to monitor backup before going to sleep; when ready to sleep the VBS runs the bat file w/ psshutdown -d

Running the vbs from task scheduler w/ highest privileges prevents UAC prompts when using PsShutdown.

You must log in to answer this question.

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