Detection of Standby or Hibernate mode

G

Guest

During standby or hibernate operation, is there any way to detect if it is an automatic (system initiative ->timeout which is configured in power management was expired) or manual operation (button press by user for example) and if it is hibernate or standby operation?

Any help would be greatly appreciated.
Thanks in advance

Regards,
Eric
 
T

Torgeir Bakken (MVP)

ECL said:
During standby or hibernate operation, is there any way to detect if it is an automatic (system initiative ->timeout which is configured in power management was expired) or manual operation (button press by user for example) and if it is hibernate or standby operation?

Hi

You can use the WMI Win32_PowerManagementEvent to detect a standby event (and maybe other things as well). Try the script below and see what you get as result.

Win32_PowerManagementEvent WMI class
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_powermanagementevent.asp

A vbscript example (will loop forever until terminated):

Set colMonitoredEvents = GetObject("winmgmts:")._
ExecNotificationQuery("Select * from Win32_PowerManagementEvent")

Do
Set strLatestEvent = colMonitoredEvents.NextEvent
Select Case strLatestEvent.EventType
Case 4
MsgBox "Entering suspend."
Select Case strLatestEvent.EventType
Case 7
MsgBox "Resuming from suspend."
Case 11
MsgBox "OEM Event happened, OEMEventCode = " _
& strLatestEvent.OEMEventCode
Case 18
MsgBox "Resume Automatic happened"
End Select
Loop
 
Joined
Dec 10, 2011
Messages
1
Reaction score
0
I realise that this is a very old post, but I'm hoping that someone will still be monitoring the thread. I have tried very hard to use this information to detect whether my system comes out of hibernation due to a scheduled task (automatically) or due to user input from a wireless keyboard (manually). Every time the system awakens, it fires code 7 first, and code 18 soon thereafter. It does not seem to matter what actually awakens the system; both codes fire every time. Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top