stay-awake-rs
Keep a Windows machine awake
Get
Executable binaries for Windows may be found at the Release page.
Usage
The executable stay-awake.exe
is intended to be run in a terminal in order to keep one's Windows machine awake.
There are two modes one may choose from:
- System [Default] → the machine will not go to sleep but the display could still turn off
- Display → the machine will not go to sleep and the display will remain on
The simplest use case is to run the executable without any switches.
stay-awake.exe
This will prevent the machine from going to sleep and will await Enter
being pressed within the terminal before resetting the machine state.
NOTE: As noted in the Win32 documentation, use of the
SetThreadExecutionState
function (which is the Win32 function called withinstay-awake
) does not prevent one from putting their computer to sleep by either closing the lid on their laptop or pressing the power button. In addition, the screen saver may still execute.
Details
Result of running stay-awake --help
stay awake ==> keep a Windows machine awake
USAGE:
stay-awake.exe [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-a, --awake-mode <awake-mode> Awake mode [default: System] [possible values: Display, System]
Testing
In order to test, open PowerShell with elevated (admin) privileges. After executing the program, run the following.
powercfg -requests
Win32 Docs
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate
Inspiration
Following along with Amos's ping series:
See Also
Created an earlier version in C#