Detection of Standby or Hibernate mode

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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?
 
Back
Top