Author Topic: How to Wake/Sleep via Task Scheduler in Windows 10 (Solved)  (Read 3008 times)

chijb55

  • Newbie
  • *
  • Posts: 7
    • View Profile
How to Wake/Sleep via Task Scheduler in Windows 10 (Solved)
« on: February 24, 2018, 02:05:14 PM »
Maybe this wasn't as hard for you as it was for me.  But after reading (countless) entries on Wake/Sleep via Task Scheduler in Windows 10, I've finally got it figured out.

My goal was to have my Arcade Cabinet - running Attract Mode - Sleep at night.  But be awake when I come downstairs in the morning to greet me <grin>.  I also combined this with a (cool and cheap) powerstrip from Home Depot with a timer, so as to turn the monitor and marquee power off at the same time.

Following is the magic Task Scheduler commands that make it work under Windows 10. 

Note:  You have to download PSTOOLS, but it's free.  Find it here:  https://docs.microsoft.com/en-us/sysinternals/downloads/pstools

NOTE:  Using Windows rundll32.exe isntead of pstools is nothing but trouble...

I scheduled 3 different events:  (1) Kill attract.exe process at 10pm (2) Sleep the PC at 1005pm (3) Wake the PC at 600am by starting a new copy of attract.exe.

Note that I leave 5 minutes between (1) Kill attract.exe and (2) Sleep the PC.  One minute was sometimes (rarely) not enough, and it caused issues.  This method works fine.

In Task Scheduler, create 3 "Basic Tasks" one at a time.  Setup On/Off times, then go to each inividual "Actions" tab and enter the following commands as indicated.  Note for the first two, nothing is entered in the optional "Start" section - this is only used for the 3rd (Wake) item.

------------------------

(1) Kill AttractMode
Setup On/Off Times, then go to the "Actions Tab"   
        Program:  taskkill.exe
   Arguments: /im attract.exe
   Start:

(2) Sleep PC
Setup On/Off Times, then go to the "Actions Tab"
   Program:  c:/pstools/psshutdown.exe
   Arguments: -d -t 0 -accepteula
   Start:

(3) WakeAttractMode
Setup On/Off Times, then go to the "Actions Tab"
   Program:   attract.exe
   Arguments:
   Start:      c:\attractmode

Every night at 10pm, AttractMode (nicely) shuts down.  5 minutes later, the PC quietly goes to sleep.  At 6am the next morning, AttractMode starts.  Make sure in WakeAttractMode that you put your OWN directory of where you have AttractMode installed (mine is c:\attractmode.)  This is the only one of the 3 that needs a "Start" option entered.

Good luck.


hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: How to Wake/Sleep via Task Scheduler in Windows 10 (Solved)
« Reply #1 on: February 27, 2018, 05:47:26 AM »
@chijb55
another solution:

>PC turn on:
depending on your pc manufactur: auto power time controlled by BIOS.
In my case is DELL the manufactur and supports it:
Here
Here
Here



>PC turn off:
create a shutdown task by sheduler. In command line :
Code: [Select]
schtasks.exe /create /tn "BEDTIME" /tr "shutdown.exe -s -f -t 1" /sc DAILY /st 20:45:00 /ru SYSTEM /fthe parameter /sc depends on your windows system language



>PC turn off:
another option is an autoit script, with sleep and shutdown command & copy the compiled .exe to autostart.

Autostart is found here:
Code: [Select]
C:\Users\Your_Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

sleep command in autoit, uses milliseconds (so 5 seconds are 5000 milliseconds).
because you're turning the pc always on same time on, so you can calculate your shutdown in milliseconds.
For example 8,5 hours are in milliseconds 30600000 ( ((8,5 * 60 ) * 60 ) * 1000 )

shutdown command 12 means ( 8 for shutdown + 4 for force = 12 )
force : close all programms and applications

Code: [Select]
sleep(30600000)
Shutdown(12)

Advantage for autoit script, against a batch shutdown : there is no notification of windows, that system shutdown in 30 minutes, 2 minutes, 1 minute and so on.



>Display and other devices turn on / off:
using a master/slave power plug strip

« Last Edit: February 27, 2018, 10:34:00 PM by hermine.potter »
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM