Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the SAGA of trying to get a computer to sleep and wake up on a schedule

Status
Not open for further replies.

Flinx

IS-IT--Management
Jul 2, 2001
53
US
Recently I needed to put a computer to sleep and wake it up in the morning at a specific time, while keeping it logged in. Simple right? WRONG! The computer also had to be logged in.

First these instructions will not be detailed step by step (google it) and are not in the order I tried them, they are in the order that should work.

You will need:
scheduled tasks that run with highest privileges, one of which wakes the computer to run.
To configure Autologon if needed (google it).
A modernish computer that supports wake timers (in the bios) from a cmd line type:
powercfg /a
look for:
The following sleep states are available on this system:
Standby (S3)
there might be others listed.
sysinternals psshutdown64.exe or psshutdown.exe
nircmd.exe... what's that? you've never heard of it? it's a wonderful command line program that does hundreds of very useful things. A batch file (we will discuss later).
Put all these files in a single non system folder.

Lets start:

disable any screensavers.
disable putting the computer to sleep automatically.
disable hibernate "powercfg -h off"

Stop Windows 10 from asking for password from sleep mode
In Settings, click on Accounts.
On the left side of the "Accounts" Settings window, click on Sign-in options.
Under Sign-in options, locate the drop down menu for Require sign-in.
select never

in regedit.exe under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power
add a Reg_Dword PlatformAoAcOverride set it to 0
this will disable "modern standby" S0. why? Because Microsoft hates you.

In an administrator cmd window issue this command:
powercfg -attributes SUB_SLEEP 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 -ATTRIB_HIDE
this will make a very important option visible. why is it not visible? because Microsoft hates you.

In control panel\power options enable wake timers, set "turn off display after" to never, and set "system unattended sleep timeout" (which you can now see) to a number of minutes that you want the computer to stay awake without keyboard or mouse movement (after a wake up) in my case 960.

Why? because microsoft decided that if you wake the computer and no one uses it in 2 minutes, it goes back to sleep. because Microsoft hates you.

To put the computer to sleep I created a task scheduler event and used sysinternals psshutdown64.exe file with the command "psshutdown64.exe -d -t 0".

Now the following solved the difficult part of getting the computer AND monitor to turn on. why would the monitor not wake up? who the ! knows!

create a bat or cmd file and add the following lines:

timeout /t 90
nircmd monitor on
if that does not work try:
nircmd async_monitor on
or
nircmd sendmouse move 1000 100

Create a task scheduler event that runs ONLY if the user is logged in (this is important), and wakes the computer to run. also in triggers set "stop task if it runs longer than" to 30 minutes. task scheduler may report the task running from the previous day. You may need to schedule a task that just runs this command 5 minutes before the wake up monitor command:
cmd /c "exit"

The scheduled event should run the batch file you just created.

now for the rant:
I needed a computer to:
autologon (if fully shutdown and then turned on).
keep the monitor on at all times.
keep the computer logged in at all times.
at a specified time put the computer to sleep in a state that it could wake up from and continue where it left off without having to login or restart programs.
wake up at a specific time.

the problems begin with the computer waking up but I had to manually login. Once that was solved the next problem was that the computer was not going to sleep in a wakeable state, it was going in to "modern sleep" (S0) which did not wake up properly. I needed the mode (S3) that shows a blinking power light. The computer cannot hibernate because hibernation requires a power button press to wake up. I could not use wake on lan because I did not want this to be reliant on another computer.

Microsoft does not want you leaving a computer running, and logged in because "muh security".

Microsoft put a hidden option so that if you commanded a computer to wake up and no one used it in 2 minutes it would go back to sleep (muh security). so I was getting the computer to wake up but it would go right back to sleep again.

If you don't enable wake timers then task scheduler cannot wake the computer to run a task.

I had to use sysinternals psshutdown because the more common (RUNDLL32.EXE powrprof.dll,SetSuspendState 0,1,0) command apparently does not work right and has never worked right.

The next major issue was that the computer would wake up but not the monitor. I tried using some simple VBS script (to issue key presses) I found on line but that did not work. there were some ridiculously complicated powershell scripts to move the mouse that I did not want to use either.

That's when I stumbled on nircmd. I powerful little stand alone program that does many many things. however it's command to move the mouse cursor did not work, nor did it's command to change display resolutions. I ran in to a problem where the nircmd monitor on would turn the monitor on and it would go right back off. I tried async_on and it did the same thing. The command that worked was a simple one: sendmouse move 1000 100. Sendmouse is different from the movecursor command.

There might have been other things I did, but I did not keep notes on everything. as of the day I posted this I have been working on this for 4 days now. I'm still not convinced it will work right. it should work, but at every step of this process it has failed when it should have worked. my googling shows I am not alone, and the last time I tried this about 7 years ago on a different computer, I never got that one to work. probably because of lack of support in the bios.
 
the sendmouse command worked and the computer woke up properly this morning.

the next step was to add a program that starts automatically after the computer is turned on or logged out and back in again.

however because this is an app from the microsoft store it is not intuitive.

the more common instructions:
select Start , then select Settings > Apps > Startup. Make sure any app you want to run at startup is turned On.

If you don’t see the Startup option in Settings, right-click (or select and hold) Start , select Task Manager, then select the Startup tab. (If you don’t see the Startup tab, select More details.) Right-click (or select and hold) the app you want to change, then select Enable to run it at startup or Disable so it doesn’t run.

didn't work because it did not show up there.

I finally found this set of instructions:
Link

1 Open File Explorer (Win+E).

2 Copy and paste shell:startup into the address bar of File Explorer, and press Enter to open your account's Startup folder.

3 Add or create a shortcut of any app, folder, drive, file, script, etc... you want to run at startup for your account into this Startup folder. Drag an APP from the start menu into that folder


easy peasy [spineyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top