Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time left until Windows suspend

Tags:

c++

c

windows

wmi

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.

like image 642
Eduardo Poço Avatar asked Dec 21 '15 14:12

Eduardo Poço


People also ask

How long does Microsoft lock you out for wrong password?

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.

How many days you can pause the Windows updates?

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.


1 Answers

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.

like image 169
egur Avatar answered Oct 04 '22 22:10

egur