https://github.com/gershnik/keep-awake
A simple tool to keep Windows machines awake
https://github.com/gershnik/keep-awake
prevent prevention sleep-mode ssh windows
Last synced: about 11 hours ago
JSON representation
A simple tool to keep Windows machines awake
- Host: GitHub
- URL: https://github.com/gershnik/keep-awake
- Owner: gershnik
- License: bsd-3-clause
- Created: 2023-04-26T21:13:08.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T16:27:19.000Z (about 3 years ago)
- Last Synced: 2025-01-02T17:50:11.564Z (over 1 year ago)
- Topics: prevent, prevention, sleep-mode, ssh, windows
- Language: CMake
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Keep-Awake
This is a small tool that allows you to prevent a Windows machine from sleeping/hibernating.
This is useful, for example, when connecting over SSH to a Windows machine that is configured to sleep when not in use.
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.
## Installation
Just drop `keep-awake.exe` for your architecture from [Releases](https://github.com/gershnik/keep-awake/releases)
anywhere on your `%PATH%`.
## Usage
`keep-awake` is a command-line application that works by launching a background copy of itself,
which prevents the computer from sleeping.
This allows you to continue your work while it is running in the background.
You can see the available command-line options by running `keep-awake --help`.
### Keep machine awake until the process is terminated
This mode is useful when connecting over SSH. The Windows SSH server kills all the child processes created within an SSH session
when the session ends. Thus, effectively, this mode keeps the computer alive while the session is active.
```bat
keep-awake
... other commands ...
```
### Keep machine awake for a specified period of time:
You can pass an optional timeout argument to `keep-awake` (see [below](#timeout-syntax) for syntax).
If **not** running over SSH:
```bat
keep-awake
... other commands ...
```
When running over SSH, you can prevent the `keep-awake` process from being killed when the SSH session ends using:
* If your shell is CMD
```bat
powershell -Command "Invoke-WmiMethod -Path 'Win32_Process' -Name Create -ArgumentList 'path\to\keep-awake '"
```
* If your shell is PowerShell
```powershell
Invoke-WmiMethod -Path 'Win32_Process' -Name Create -ArgumentList 'path\to\keep-awake '
```
#### Timeout syntax
The syntax for `` can be a single number - this is interpreted as seconds.
Or, you can use a full format:
```
"d h m [s]"
```
For days, hours, minutes and seconds. Every part is optional, but at least one must be present.
You can use any number of spaces (including none) anywhere in the string, but if you do, you will need to
wrap the string in `"` to make it one command-line argument.
### Listing currently active instances
You can list currently active background instances of `keep-awake` and how long they have left
to run.
```
keep-awake list
```
### Stopping an instance
You can stop running instances of `keep-awake` via:
```
keep-awake stop pid [pid ...]
```
where `pid` is a process ID of a running instance. The process IDs are reported when you launch `keep-awake`
or when using the `list` command.
Alternatively, you can always terminate an instance using Task Manager or a similar tool.
### Color output
Since version 2.1.0, `keep-awake` supports colored output if the output is printed on a terminal that supports
colors. You can override this behavior using environment variables [NO_COLOR](https://no-color.org) and
[FORCE_COLOR](https://force-color.org). If both are set, `NO_COLOR` takes precedence.
## Building
Clone this repository and open its folder in Visual Studio 2022 or later as a CMake project.