Is there a way to query windows how much time is left until it goes to suspend/sleep mode?
I am using vbscript and suspect there might be a WMI answer, but any language like c/c++, *.NET, or even java, if possible, may fit my needs.
EDIT
I want to be able to query Windows with a method, not to be alerted by events when it is about to suspend.
If Account lockout threshold is configured, after the specified number of failed attempts, the account will be locked out. If the Account lockout duration is set to 0, the account will remain locked until an administrator unlocks it manually. It's advisable to set Account lockout duration to approximately 15 minutes.
Select either Pause updates for 7 days or Advanced options. Then, in the Pause updates section, select the drop-down menu and specify a date for updates to resume. Note: After the pause limit is reached, you'll need to install the latest updates before you can pause updates again.
There's no API to know how much time is left since Windows will try to complete entering S3 (Sleep) or S4 (Hibernate) as quick as possible.
Windows will send a notification to all processes about the pending power state change and allow applications to prepare for that event.
You can find most of what you need here.
Basically you have 20 seconds to process the first message. Your process can delay replying to the message, taking care of all the various power cycle tasks, e.g. close files, save your state, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With