
A Windows-only VS Code extension that prevents automatic system sleep while enabled. It calls the native Windows SetThreadExecutionState API through a bundled PowerShell helper. It does not simulate keyboard input and does not change the active Windows power plan.
Requirements
- To use it: Windows 10/11, VS Code
1.90.0or later. The helper relies on Windows PowerShell 5.1, which ships with Windows -- nothing extra to install. - To build it: Node.js and npm. There are no npm packages to install (no
dependencies/devDependenciesinpackage.json); packaging fetches@vscode/vsceon demand vianpx. - To test it: nothing beyond the above -- the test script runs with Windows PowerShell and does not require administrator rights.
Default behavior
- Enables automatically after VS Code starts.
- Prevents automatic system sleep.
- Allows the display to turn off normally.
- Shows an
Awakestatus-bar item; click it to toggle. - Releases the power request when disabled or when the VS Code extension host exits.
This does not block an explicit Sleep command, shutdown, restart, hibernation initiated by policy, or forced sleep caused by critical battery conditions.
Install
From the Marketplace:
- Open VS Code.
- Open the Extensions view (
Ctrl+Shift+X) and search forjfceb3.vscode-keep-windows-awake, or go to the Marketplace listing and click Install.
From a .vsix (e.g. a GitHub Release):
Repository: github.com/jfceb3/vscode-keep-windows-awake
- Open VS Code.
- Open the Command Palette with
Ctrl+Shift+P. - Run Extensions: Install from VSIX....
- Select
vscode-keep-windows-awake.vsix. - Reload VS Code if prompted.
Alternatively:
code --install-extension .\vscode-keep-windows-awake.vsix
Commands
VS Code Keep Windows Awake: EnableVS Code Keep Windows Awake: DisableVS Code Keep Windows Awake: ToggleVS Code Keep Windows Awake: Show Status
Settings
vscodeKeepWindowsAwake.enableOnStartup: enable automatically when VS Code starts. Default:true.vscodeKeepWindowsAwake.keepDisplayOn: also keep the display on. Default:false.vscodeKeepWindowsAwake.showStatusBar: show the status-bar control. Default:true.
Security and privacy
- No network access.
- No telemetry or analytics.
- No simulated keyboard or mouse input.
- No administrator rights requested.
- The helper is plain-text PowerShell included in
helper/keep-awake.ps1for inspection. - PowerShell is launched with
-ExecutionPolicy Bypassfor this one helper process; it does not change the machine or user execution policy.
Build from source
npm run package
The .vsix will be created in the project root.
Testing
test/verify-sleep-behavior.ps1 verifies the extension's actual effect on Windows sleep behavior, not just that the helper process runs. It needs an interactive terminal (it pauses for you to toggle the status bar between phases). From Powershell:
.\test\run-test.bat
It temporarily shortens your sleep/display timeouts to 1 minute, walks you through testing both the "Awake" and "Sleep allowed" states, locks the workstation for each, and checks the Windows event log (Microsoft-Windows-Power-Troubleshooter) for an actual sleep event -- expecting none while "Awake" and one while "Sleep allowed". Your original power settings are captured up front and always restored afterward, with the restored values verified against the originals.