Is it possible to apply a time frame to Windows 7 power settings?

The problem: I want my desktop computer to use the High Performance power mode whenever I'm at work, to minimize UI lag, etc. When I'm not at work, I want to enable Power Saver mode.

I'd like to do this by saying "From 8AM to 5PM Mon-Fri, set the power mode to High Performance. At all other times, set the power mode to Power Saver."

Is anyone aware of a way to do this?


Is it possible to apply a time frame to Windows 7 power settings?

powercfg can be used from the command line to set the active power scheme.

High-Performance:

powercfg -s SCHEME_MIN

Power Saver:

powercfg -s SCHEME_MAX

To apply these schemes at certain times use the Task Scheduler.


Schedule a task

You must be logged on as an administrator to perform these steps. If you aren't logged on as an administrator, you can only change settings that apply to your user account.

...

  1. Open Task Scheduler by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Task Scheduler.‌ Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

  2. Click the Action menu, and then click Create Basic Task.

  3. Type a name for the task and an optional description, and then click Next.

  4. Do one of the following:

    • To select a schedule based on the calendar, click Daily, Weekly, Monthly, or One time, click Next; specify the schedule you want to use, and then click Next.

    • To select a schedule based on common recurring events, click When the computer starts or When I log on, and then click Next.

    • To select a schedule based on specific events, click When a specific event is logged, click Next; specify the event log and other information using the drop-down lists, and then click Next.

  5. To schedule a program to start automatically, click Start a program, and then click Next.

  6. Click Browse to find the program you want to start, and then click Next.

  7. Click Finish.

Note:

  • The program top run can be a batch file containing one of the powercfg commands mentioned previously.

Source Schedule a task


Further reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • powercfg - Control power settings, configure Hibernate/Standby modes.
  • schtasks - Create / edit a Scheduled Job/Task. The job can be created on the local or a remote computer.

In addition to @DavidPostill's answer, here's the final PowerShell script I ended up using:

$currentTime = Get-Date
$endTime = [datetime] "18:00:00"
$timeDiff = $currentTime.hour - $endTime.hour

write-Host -ForegroundColor yellow $timeDiff
if ($timeDiff -gt 0)
{
    write-Host -ForegroundColor yellow "Changing power plan to 'Power saver'." 
    PowerCfg -s SCHEME_MAX
}
else
{
    write-Host -ForegroundColor yellow "Changing power plan to 'High performance'." 
    PowerCfg -s SCHEME_MIN
}

It might have a few bugs related to the time ranges, but it should give anyone else a good idea of what the script could look like.