WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Detect Standby or Hibernation Event

 Keywords: Detect Determine Standby or Hibernate Power Management Event 

Question:

How do I detect pc going in hibernation or standby mode?

Answer:

objWinmgmts = ObjectGet("winmgmts:")
colMonitoredEvents = objWinmgmts.ExecNotificationQuery("Select * from Win32_PowerManagementEvent")

While @TRUE
    objLatestEvent = colMonitoredEvents.NextEvent
    ;Message( "A power management event happened", "Event type: ":objLatestEvent.EventType)
    Switch objLatestEvent.EventType
      Case 4   ;Entering suspend,
         Message( "PowerManagementEvent", "Entering suspend")
         Break
      Case 7
         Message( "PowerManagementEvent", "Resuming from suspend")
         Break

      Case 11
         Message( "PowerManagementEvent", "OEM Event happened OEMEventCode = " : objLatestEvent.OEMEventCode)
         Break

      Case 18
      Message( "PowerManagementEvent", "Resume Automatic happened")
      Break
    EndSwitch
EndWhile
objWinmgmts = 0


Article ID:   W18469
Filename:   Detect Standby or Hibernation Event.txt
File Created: 2010:06:23:12:42:56
Last Updated: 2010:06:23:12:42:56