3

I want my laptop to sleep after an hour of being idle (and plugged in), but ONLY outside of work hours (eg: 8am-5pm Mon-Fri). I'm not trying to disable sleep entirely during work hours, it just has to be done manually (unless on battery).

What are the best ways to achieve this?

Some ideas I've had:

  • Set the Power Plan settings to never sleep, and use the task scheduler to run a command to tell the PC to sleep under certain conditions. I'm not sure though if the logic can be set up in a way that disables the condition during a time window and checks for inactivity otherwise.
  • Use the task scheduler to disable sleep-on-idle timer as part of the power plan at 8am, then set the time to 1 hour at 6pm. This solution would need to leave the On-battery sleep timer active at all times.

Windows power plan idea

I'm specifically using Windows 10 on a laptop, but an ideal solution would work for other configurations as well.

Bort
  • 1,714

3 Answers3

1

You can use the windows task scheduler to run a script after the PC becomes idle and limit it to a certain time frame under trigger.

enter image description here

If you want to make sure it's idle for a specific amount of time you can use the conditions tab (see here)

enter image description here

In my script I use psshutdown with the following command psshutdown -d -t 0 to put the PC to sleep.

Albin
  • 11,950
1

This can be achieved by creating a task to enable sleep-on-idle in the evening and disable sleep-on-idle in the morning. We can implement this using the Task Manager and powercfg.

Create a New Task

Select: ⊞ (Start) > Task Scheduler > Action > Create Task…

Give the task a meaningful Name like "Enable Sleep". Since this involves controlling hardware, I also enabled "Run with highest privileges".

Task Properties Window Screenshot

Configure a Daily Schedule

Select: Triggers > New…

Begin the task: On a Schedule, Daily, Start: 5pm or whenever you stop work

Configure PowerCfg Action

Go to Actions tab > New…

Set "Action" to "Start a Program" and Program/script to powercfg /CHANGE standby-timeout-ac 30. Windows should prompt you to move the arguments to a second field, which you should accept. You can change 30 to the number of minutes you want the computer to idle before shutting off. However, I would ensure this is at least 11 so that Windows has enough time to run powercfg in the morning before it sleeps again.

New Trigger Window Screenshot

Disable Sleep in the Morning

Now create another task "Disable Sleep". This is rather similar, but the number at the end of the powercfg command should be 0 rather than 30, and go to the Setting tab and enable "Run task as soon as possible after scheduled start is missed".

Settings Tab Screenshot

Giacomo1968
  • 58,727
gmatht
  • 2,437
0

Windows Sleep (Windows 7 and above) is designed to operate after a specific time interval. For my laptop, I just close the lid when needed. For a desktop, it seems as easy to suspend when done or (as you are suggesting) make a task to run at 6:00 pm (say) each day to run Power Manager which will then Sleep after an interval.

Another thought - my desktop now has an SSD drive and I just let it run. Monitor turns off after 20 minutes of non-use but the machine does not suspend. No real need.