StayAwake (Updated)

  • Post comments:0 Comments

Good day everyone! Some time ago, I created myself a little tool to prevent my computer from going to sleep or standby. I worked with it the last couple of years but lately I thought about an option to disable the tool at a certain time, like “Keep my PC alive until 7 pm and then give the control back to the power options to allow the PC to sleep”.

I know there are plenty of “keep alive” tools available in the internet. Microsoft’s Power Toys, for example, can also do this. But none of them I tried provided a “stay-awake-until” option. Honestly, I only tested a few.

So I reviewed the old StayAwake. I removed the timer and added a disable at option, which makes more sense in my eyes. Then I wondered if it really needs a GUI for a simple on/off functionality and for very few options. I created a new log class, a new arguments class, reviewed the config class, in short words: I created a new application.

Here’s how you can use it.

Installation

  1. After downloading the ZIP file, extract StayAwake.exe to a directory of your choice. I suggest you to copy it to the local AppData folder, i.e. C:\Users\<username>\AppData\Local\StayAwake
  2. Open a command prompt in user mode, change to the StayAwake directory and enter following command:
    StayAwake.exe /autostart
    This creates a link to StayAwake.exe in the shell:startup folder (C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup)
  3. Press Win + I -> Personalization -> Taskbar -> expand Other Taskbar Settings -> Turn StayAwake on

Features / Configuration

Stay awake can be turned on/off by simple clicking the tray icon. When active, the icon shows a little flash overlay.

The application stores its settings in the Windows Registry within HKEY_CURRENT_USER\Software\StayAwake. Some settings are accessible from the context menu of the application’s tray icon.

Other settings require additional effort like changing the registry or running a command. Here are the details:

Active
Value: Active
Type: REG_DWORD
Context Menu: Yes
Description: If Active is checked (or set to DWORD: 0x1) your PC does not sleep or hibenate.

Leave Screen on
Value: ScreenActive
Type: REG_DWORD
Context Menu: Yes
Description: When checked (or set to DWORD: 0x1) the screen stays on. This is only effective, when Active is on and System is on.

Leave System on
Value: SystemActive
Type: REG_DWORD
Context Menu: Yes
Description: When checked (or set to DWORD: 0x1) your PC does not sleep or hibernate. This is only effective, when Active is on.

Disable At
Value: DisableAt
Type: REG_SZ
Context Menu: No
Description: When set, StayAwake disables itself at the specified time. Please note that the time value must be readable for the .Net DateTime.Parse function. Only time values are considered. Date values will be ignored.

Example:
If you want StayAwake to be disable at 19:00 (7 pm), enter following command line into a command prompt:

reg.exe ADD "HKEY_LOCAL_MACHINE\SOFTWARE\StayAwake" /f /t REG_SZ /v "DisableAt" /d "19:00"

Debug Log

StayAwake can write essential log information to the application event log. However, it cannot create the log source due to missing administrative rights. The log source can be created manually by running following Powershell command from an elevated Powershell window:

New-EventLog -LogName "Application" -Source "StayAwake"

Leave a Reply