Your last post confuses me.
sambul35 wrote:Windows Power Management code definitely has a view on what constitutes "no activity" on the PC thus allowing to put it to sleep.
No.
Windows just checks the "user input" and the system idle timer may expire somewhen if no input is detected:
You could costumize this timer duration under the Power Plan settings.
sambul35 wrote:Thanks for the detail analysis of options available.
This is the most confusing part.
My last post doesn't list options available, it should be read as (i misused a quote block for that):
The term "no activity" is not defined, so i asked you to define "no activity" by yourself.
(+ explaination why "no activity" cannot be defined in common)
(+ some partial solution how to test your definition parts, once you have defined it).
Sidenote (because i'm unsure):
If your definition of "no activity" is "no activity := no user input", and you don't need to set anything before going to sleep or restore anything after "woken", then i would recommend you just to edit the value of the system idle timer; Win 8.1. sample image:
http://www.apricorn.com/media/faq_images/windows_setting_1.PNGIn that case you just don't need any batch.
I expected that you to do something like this (kind of Roadmap of what i once thought you wanted to program - i hope i have not misinterpreted your above posts on this):
1) Create a definition similar to the following:
Sample Definition: ("no activity"; for hypothetical me "no activity" means)
"no activity" := (
"Software XYZ is not running" AND
"no user input" AND
"no network activity on port 123"
)
Write a function that checks these parts:
- "Software XYZ is not running" with "tasklist.exe"
- "no user input" my above c# application
- "no network activity on port 123" (actually not implemented at all, because i don't know if you would ever need it)
Then you should encapsulate it in the batch "function" ":noActivity" which sets the errorlevel to 1 if "no activity" is found, else 0.
2) Encapsulate all what you want to do before "going to sleep" in the batch function ":before".
3) Encapsulate all what you want to do after "waking" in the batch function ":after".
4) Then the batch file (i thought you were asking for) is this:
Code: Select all
@echo off
call :noActivity
if errorlevel 1 (
call :before
call "Suspend.bat"
call :after
)
goto :eof
:noActivity
:: ... (your implementation)
:before
:: ... (your implementation)
:after
:: ... (your implementation)
5) Use the task scheduler to start this batch in intervals of your choice.
Another Sidenote:
You don't need to modify the Systems Power Plan to set the system to sleep:
The "Suspend.bat" works no matter which power plan is active.
So i thought
this batch is the "certain service" you want to stop, before you suspend the pc (+restore it after "rewoken").
penpen