Meine freeware







 cPOS Skin

The situation:
The Windows-PC is in state "Hibernation" (or Standby) and is woken up by a keypress or WOL.
Now there is a so-called unattended idle timer that sets the system back to hibernation or standby after an unconfigurable time interval. Only direct interaction using keyboard or mouse disables this idle timer and enables Windows to act according to the current power scheme. In some cases this behaviour is annoying!

For Windows XP, like I said, the interval of this timer is unconfigurable. I read, it's about 120 seconds. In my case it was some 9 minutes (maybe 512 seconds?)

The solution:
So a different solution must be found: The API-function SetThreadExecutionState() can tell the OS to reset the timer and delay the return-to-sleep for as long as you want. I found a code snipplet on the internet, that not yet did exactly what I wanted, but I extended the code and finished the small Windows-Service, that now keeps my system awake after returning from hibernation!

The simple option, a flag for SetThreadExecutionState() that theoretically should work, didn't, so I built in a 60-seconds-timer, that resets the idle timer explicitly until the user interacts. On interaction, this timer is stopped and everything is back to normal.

Version 1.0.3: A new feature is the ability to execute a user-defined command after wake-up. This command must be stored in the first line of a file named "StayAwakeExec.txt" in the same directory as StayAwake.exe.
A delay can be defined, to make StayAwake execute the command after a certain time after wake-up. This delay (in seconds!) is put in front of the command-line, followed/separated by a "?".

Examples of "StayAwakeExec.txt":

C:\WINDOWS\notepad.exe /wakeup (Parameters are supported)
"C:\Program files\tools.cmd" (paths containing spaces must be in quotes)
10?"C:\Programme\Mein Skript.vbs" (this would cause a delay of 10 seconds before the execution of the command)

This TXT file is read on every automatic wake-up of the system, when StayAwake is running.

If the tool you specify needs interaction (window/DOS box) for in- or output, the StayAwake-service (installation below), must be configured to "Allow interaction with Desktop!".

Version 1.0.4: The "SetThreadExecutionState()" is deactivated in the event method (on wakeup and user interaction), because it caused my display to flicker shortly on first user interaction and thus causing my TV app to hang. The SetThreadExecutionState() is only called in the KeepAliveTimer method now.

Version 1.0.5: Minor enhancements regarding messages in the event log and the debug mode.

Version 1.0.6: Important bug fixes / enhancements in the StayAwakeExec.txt - functionality.

Download binary StayAwake.exe (Current Version: 1.0.6)
Download source StayAwake.cs

Build / install:
Compiling may be done by anyone who likes to, in any way he likes to. The others may use the Win32-binary. Installing works as follows:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe <...Path...>\StayAwake.exe <-- registeres the program as a service.
Now it can be started with the service manager, but will be active after a reboot anyway.

Logging is done into the Windows-eventlog. For more logging output, add /debug after "StayAwake.exe" (in the service-image registry ;) )

GPL (GNU General Public License, open source)
This software is delivered "as is", without any warranty. Use at own risk!
Bugs may be reported and might be fixed on a "free-will" basis.

Last Update: