This is a small tool that allows you prevent a Windows machine from sleeping/hybernating. This is useful, for example, when connectiong to a Windows machine that is configured to sleep when not used over SSH.
Unlike other solutions to this task keep-awake
doesn't change global computer settings and so doesn't leave
them 'orphaned' if it is abnormally terminated.
Just drop keep-awake.exe
from Releases anywhere on your %PATH%
.
This mode is usefull when connecting over SSH. All the child processes created within SSH session are automatically killed when the session ends. Thus, effectively this mode keeps the computer alive while the session is active.
keep-awake
... other commands ...
If not running over SSH:
keep-awake seconds-to-keep-awake
... other commands ...
If running over SSH to prevent the process from being killed when SSH session ends you can do this:
- If your shell is CMD
powershell -Command "Invoke-WmiMethod -Path 'Win32_Process' -Name Create -ArgumentList 'path\to\keep-awake seconds-to-keep-awake'"
- If your shell is Powershell
Invoke-WmiMethod -Path 'Win32_Process' -Name Create -ArgumentList 'path\to\keep-awake seconds-to-keep-awake'
Clone this repository and open its folder in Visual Studio as a CMake project.