Skip to main content

Overview

Awake is a utility that prevents Windows from entering sleep mode or turning off the display. It provides flexible control over your computer’s power state with support for indefinite, timed, and process-bound keep-awake modes.
Awake uses the Win32 SetThreadExecutionState() API with ES_SYSTEM_REQUIRED and ES_DISPLAY_REQUIRED flags.

Activation

1

Enable via PowerToys

Open PowerToys Settings and enable Awake in the utilities list
2

Configure Mode

Choose from PASSIVE, INDEFINITE, TIMED, or EXPIRABLE modes
3

Access via Tray Icon

Right-click the Awake system tray icon for quick mode changes

Standalone Command-Line Usage

Awake can also run independently with CLI arguments:
PowerToys.Awake.exe [options]

Key Features

Operating Modes

PASSIVE

Normal power behavior (utility disabled)System can sleep normally

INDEFINITE

Keep awake until manually stoppedMost common mode for extended work

TIMED

Keep awake for specific durationExample: 2 hours, 30 minutes

EXPIRABLE

Keep awake until specific date/timeExample: Until 11:59 PM today

Display Control

Independent control of display sleep behavior:
// Power state flags used by Awake
ES_SYSTEM_REQUIRED   // Prevents system sleep
ES_DISPLAY_REQUIRED  // Prevents display sleep
ES_CONTINUOUS        // Maintains state until changed
Task Scheduler Limitation: When “Keep display on” is enabled, Windows Task Scheduler cannot detect system as idle. This prevents scheduled maintenance tasks (TRIM, defragmentation) from running automatically.See Known Limitations for workarounds.

Timed Operation

Set duration-based keep-awake periods:
# Keep system awake for 1 hour
PowerToys.Awake.exe --time-limit 3600

# Keep awake for 2 hours with display on
PowerToys.Awake.exe --time-limit 7200 --display-on
Time limit specified in seconds.

Expiration Scheduling

Keep system awake until specific date/time:
# Keep awake until end of day
PowerToys.Awake.exe --expire-at "2026-03-04 23:59:59"

# Keep awake until specific time
PowerToys.Awake.exe --expire-at "2026-03-04 17:30:00" --display-on

Process Binding

Bind Awake to another process lifecycle:
# Keep awake while process 1234 is running
PowerToys.Awake.exe --pid 1234

# Bind to parent PowerToys process
PowerToys.Awake.exe --use-parent-pid
When bound process terminates, Awake automatically exits.

System Tray Integration

Awake provides a custom tray icon implementation:
// Pure Win32 API for minimal footprint (no WPF/WinForms)
// Uses Shell_NotifyIcon API for tray management
// Custom SynchronizationContext for thread-safe UI updates
Right-click tray icon to:
  • Switch between operating modes
  • Toggle display keep-awake
  • Set timed durations
  • Open PowerToys Settings
  • Exit Awake

Configuration

Settings Location

When using PowerToys integration:
%LOCALAPPDATA%\Microsoft\PowerToys\Awake\settings.json

Command-Line Options

--use-pt-config
flag
Use PowerToys configuration file instead of command-line settingsShort: -c
--display-on
flag
Keep display on (prevents monitor sleep)Short: -dDefault: false
--time-limit
number
Time limit in secondsShort: -tExample: 3600 (1 hour)
--pid
number
Process ID to bind toShort: -pBehavior: Awake exits when specified process terminates
--expire-at
datetime
Expiration date and timeShort: -eFormat: YYYY-MM-DD HH:MM:SS
--use-parent-pid
flag
Bind to parent process automaticallyShort: -uUse case: When launched by PowerToys runner

PowerToys Settings UI

Configure Awake through PowerToys Settings:
  1. Mode Selection: Choose operating mode from dropdown
  2. Display Keep-Awake: Toggle display sleep prevention
  3. Duration Picker: Set hours and minutes for timed mode
  4. Expiration Picker: Choose date and time for expirable mode

Use Cases

Long-Running Operations

Prevent sleep during overnight builds:
# Start build then enable Awake
msbuild LargeSolution.sln /m
# Enable INDEFINITE mode via tray icon
Or use timed mode:
PowerToys.Awake.exe --time-limit 28800  # 8 hours
Keep system awake during data analysis or ETL jobs:
# Bind Awake to Python process
$process = Start-Process python analyze_data.py -PassThru
PowerToys.Awake.exe --pid $process.Id --display-on
Prevent sleep during large file uploads or downloads:
  1. Start file transfer
  2. Enable Awake INDEFINITE mode
  3. Disable “Keep display on” to save power
  4. Disable Awake when complete

Presentations & Meetings

1

Before Meeting

Enable Awake INDEFINITE mode with display keep-awake
2

During Meeting

System and display remain active without interaction
3

After Meeting

Disable Awake or use timed mode (e.g., 2-hour meeting)
# Set up for 2-hour presentation
PowerToys.Awake.exe --time-limit 7200 --display-on

Development & Testing

Server Testing

Keep system awake while running local development servers
# Bind to Node.js server process
node server.js &
PowerToys.Awake.exe --pid $!

Automated Testing

Prevent sleep during long test suite runs
# Run tests with Awake
PowerToys.Awake.exe --time-limit 3600
pytest tests/ --verbose

Database Operations

Keep awake during database migrations or backups
# Expire when maintenance window ends
PowerToys.Awake.exe --expire-at "2026-03-05 06:00:00"

Monitoring Dashboards

Display monitoring systems without sleepEnable INDEFINITE with display on

Media & Downloads

Common scenarios:
  • Video Rendering: Keep system awake during video export
  • Batch Downloads: Prevent sleep while downloading large files
  • Media Streaming: Maintain display during video playback
  • Music Playback: Keep system active for extended listening

Technical Details

Architecture

Design Highlights

No WPF/WinForms dependencies for minimal binary size
// Direct Shell_NotifyIcon API usage
// Custom SynchronizationContext for thread-safe updates
// Tray operations run on dedicated thread
File: src/modules/awake/Awake/Core/TrayHelper.cs

Key Components

ComponentPurposeFile
Program.csEntry point & CLI parsingsrc/modules/awake/Awake/Program.cs
Manager.csState orchestration & power managementsrc/modules/awake/Awake/Core/Manager.cs
TrayHelper.csSystem tray UI managementsrc/modules/awake/Awake/Core/TrayHelper.cs
Bridge.csWin32 P/Invoke declarationssrc/modules/awake/Awake/Core/Native/Bridge.cs

Dependencies

<!-- From Awake.csproj -->
<PackageReference Include="System.CommandLine" />  <!-- CLI parsing -->
<PackageReference Include="System.Reactive" />     <!-- Rx.NET timers -->
<PackageReference Include="PowerToys.ManagedCommon" />
<PackageReference Include="PowerToys.Settings.UI.Lib" />
<PackageReference Include="PowerToys.Interop" />

Known Limitations

Task Scheduler Idle Detection

Issue: When “Keep display on” is enabled (ES_DISPLAY_REQUIRED flag), Windows Task Scheduler cannot detect system as idle.Impact:
  • Scheduled maintenance tasks won’t run automatically
  • SSD TRIM operations may be delayed
  • Disk defragmentation skipped
  • Other idle-triggered tasks postponed
Microsoft Documentation:
“An exception would be for any presentation type application that sets the ES_DISPLAY_REQUIRED flag. This flag forces Task Scheduler to not consider the system as being idle, regardless of user activity or resource consumption.”
GitHub Issue: #44134

Workarounds

Only use ES_SYSTEM_REQUIRED without ES_DISPLAY_REQUIRED:
  • Prevents system sleep
  • Allows Task Scheduler idle detection
  • Display can still turn off
Configuration: Uncheck “Keep display on” in Awake settings
Run maintenance tasks manually when needed:
# Run TRIM manually (as Administrator)
Optimize-Volume -DriveLetter C -ReTrim -Verbose

# Check defragmentation status
Optimize-Volume -DriveLetter C -Analyze -Verbose

# Run defragmentation
Optimize-Volume -DriveLetter C -Defrag -Verbose
Use timed or expirable modes to allow maintenance windows:
# Work hours only (8 AM to 6 PM)
PowerToys.Awake.exe --expire-at "2026-03-04 18:00:00"

# Allows overnight maintenance tasks

Troubleshooting

Possible causes:
  • Awake not running (check system tray)
  • Mode set to PASSIVE
  • Group Policy overriding power settings
  • Laptop lid closed (triggers sleep regardless)
Solutions:
  1. Verify Awake tray icon is present
  2. Check current mode in tray menu
  3. Review Group Policy power settings
  4. Use external monitor with lid closed
Check:
  • “Keep display on” is enabled in Awake settings
  • Display timeout in Windows power settings
  • Screen saver is disabled
Note: Some applications may override display settings
Troubleshooting:
  1. Check if PowerToys is running
  2. Look in system tray overflow area
  3. Restart PowerToys
  4. Check Windows notification area settings
Implementation: src/modules/awake/Awake/Core/TrayHelper.cs
Verify:
  • Time limit is set correctly (in seconds)
  • System clock is accurate
  • No configuration file changes overriding timer
Debug: Check Awake logs in %LOCALAPPDATA%\Microsoft\PowerToys\Awake\Logs

See Also

Resources

Build docs developers (and LLMs) love