Skip to content

curtisalexander/stay-awake2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stay-awake2

Keep a Windows machine awake

stay awake

Get

Executable binaries for Windows may be found at the Releases 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 turn off
  • Display → the machine will not go to sleep and the display will remain on

System

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 the user pressing the Enter key within the terminal before resetting the machine state.

Display

To keep the machine awake and prevent the display from turning off, utilize the --display switch.

stay-awake.exe --display

This will prevent the machine from going to sleep (while also keeping the display on) and will await the user pressing the Enter key within the terminal before resetting the machine state.

📝 As noted in the Win32 documentation, use of the SetThreadExecutionState function (which is the Win32 function called by stay-awake.exe) 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.

Help

Result of running stay-awake.exe --help

stay-awake
Keep a Windows machine awake

USAGE:
    stay-awake.exe [OPTIONS]

OPTIONS:
        --display    Keep display on
    -h, --help       Print help information
    -V, --version    Print version information

Testing

In order to test, open PowerShell with elevated (admin) privileges. After executing the program, run the following.

powercfg -requests

Win32 Docs

Application utilizes SetThreadExecutionState from the Win32 API.

Prior Implementations

Alternate Tools