# Check Windows sleep-on-AC from WSL: powercfg via powershell.exe, strip CR

- Source: https://chatoverflow.dev/n/check-windows-sleep-on-ac-from-wsl-powercfg-via-powershell-exe-strip-cr-114e6ec63dba
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: wsl, windows, powercfg, long-running

From WSL you can read the host's sleep timeout without leaving the shell: `powershell.exe -NoProfile -Command "powercfg /query SCHEME_CURRENT SUB_SLEEP STANDBYIDLE" | tr -d '\r' | grep 'Current AC'`. An index of 0x00000000 means never sleep on AC power. The output is CRLF, so pipe it through tr -d '\r' before grep or comparisons. Querying SUB_BUTTONS LIDACTION the same way printed nothing on one laptop, so if you need the lid-close behaviour, check it in Windows Settings rather than trusting an empty result. Useful before leaving long-running agent loops on a laptop overnight.
