Detect Restart from Hybernate or Stand By

H

Harlan Grove

Is there a way to detect restarting from hybernate or stand by states
that I could use to run batch files?

My laptop has a mouse touchpad controller applet that puts an icon
into the system tray. I'm in the habit of hiding that icon whenever it
appears. It appears every time my laptop restarts from hybernate or
stand by states, so I figure there's a background process that puts
the icon back in the system tray on restart. While one of the things I
want to do is automate hiding this icon, I'd also like to check and do
other things on restarts.
 
B

billious

Harlan Grove said:
Is there a way to detect restarting from hybernate or stand by states
that I could use to run batch files?

My laptop has a mouse touchpad controller applet that puts an icon
into the system tray. I'm in the habit of hiding that icon whenever it
appears. It appears every time my laptop restarts from hybernate or
stand by states, so I figure there's a background process that puts
the icon back in the system tray on restart. While one of the things I
want to do is automate hiding this icon, I'd also like to check and do
other things on restarts.

Perhaps this might be of use :
http://www.pcreview.co.uk/forums/thread-1495473.php

Pertinent portion of the response:


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/e...gementevent.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
 
D

Dean Wells \(MVP\)

Harlan Grove said:
Is there a way to detect restarting from hybernate or stand by states
that I could use to run batch files?

My laptop has a mouse touchpad controller applet that puts an icon
into the system tray. I'm in the habit of hiding that icon whenever it
appears. It appears every time my laptop restarts from hybernate or
stand by states, so I figure there's a background process that puts
the icon back in the system tray on restart. While one of the things I
want to do is automate hiding this icon, I'd also like to check and do
other things on restarts.


I imagine there are any number of ways to do this, since I use Vista,
I've configured a scheduled task that's triggered by the event that's
logged during resume (see the exported & detailed info. below) -

Log Name: System
Source: Microsoft-Windows-Power-Troubleshooter
Date: 6/17/2008 12:20:06 PM
Event ID: 1
Task Category: None
Level: Information
Keywords:
User: LOCAL SERVICE
Computer: CUBE
Description:
The system has resumed from sleep.

Sleep Time: 6/17/2008 4:18:31 PM
Wake Time: 6/17/2008 4:19:46 PM

Wake Source: Device -ACPI Sleep Button
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Power-Troubleshooter"
Guid="{cdc05e28-c449-49c6-b9d2-88cf761644df}" />
<EventID>1</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2008-06-17T16:20:06.868Z" />
<EventRecordID>190913</EventRecordID>
<Correlation ActivityID="{0CFCA687-1520-42FE-8B54-462E78B6100C}" />
<Execution ProcessID="1136" ThreadID="2216" />
<Channel>System</Channel>
<Computer>CUBE</Computer>
<Security UserID="S-1-5-19" />
</System>
<EventData>
<Data Name="SleepTime">2008-06-17T16:18:31.328Z</Data>
<Data Name="WakeTime">2008-06-17T16:19:46.983Z</Data>
<Data Name="SleepDuration">14665</Data>
<Data Name="WakeDuration">492</Data>
<Data Name="DriverInitDuration">399</Data>
<Data Name="BiosInitDuration">481</Data>
<Data Name="HiberWriteDuration">23241</Data>
<Data Name="HiberReadDuration">0</Data>
<Data Name="HiberPagesWritten">0</Data>
<Data Name="Attributes">20499</Data>
<Data Name="TargetState">4</Data>
<Data Name="EffectiveState">5</Data>
<Data Name="WakeSourceType">4</Data>
<Data Name="WakeSourceTextLength">17</Data>
<Data Name="WakeSourceText">ACPI Sleep Button</Data>
</EventData>
</Event>
 
P

pudway56

Dean Wells (MVP) said:
Harlan Grove said:
Is there a way to detect restarting from hybernate or stand by states
that I could use to run batch files?

My laptop has a mouse touchpad controller applet that puts an icon
into the system tray. I'm in the habit of hiding that icon whenever it
appears. It appears every time my laptop restarts from hybernate or
stand by states, so I figure there's a background process that puts
the icon back in the system tray on restart. While one of the things I
want to do is automate hiding this icon, I'd also like to check and do
other things on restarts.


I imagine there are any number of ways to do this, since I use Vista,
I've configured a scheduled task that's triggered by the event that's
logged during resume (see the exported & detailed info. below) -

Log Name: System
Source: Microsoft-Windows-Power-Troubleshooter
Date: 6/17/2008 12:20:06 PM
Event ID: 1
Task Category: None
Level: Information
Keywords:
User: LOCAL SERVICE
Computer: CUBE
Description:
The system has resumed from sleep.

Sleep Time: 6/17/2008 4:18:31 PM
Wake Time: 6/17/2008 4:19:46 PM

Wake Source: Device -ACPI Sleep Button
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Power-Troubleshooter"
Guid="{cdc05e28-c449-49c6-b9d2-88cf761644df}" />
<EventID>1</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2008-06-17T16:20:06.868Z" />
<EventRecordID>190913</EventRecordID>
<Correlation ActivityID="{0CFCA687-1520-42FE-8B54-462E78B6100C}" />
<Execution ProcessID="1136" ThreadID="2216" />
<Channel>System</Channel>
<Computer>CUBE</Computer>
<Security UserID="S-1-5-19" />
</System>
<EventData>
<Data Name="SleepTime">2008-06-17T16:18:31.328Z</Data>
<Data Name="WakeTime">2008-06-17T16:19:46.983Z</Data>
<Data Name="SleepDuration">14665</Data>
<Data Name="WakeDuration">492</Data>
<Data Name="DriverInitDuration">399</Data>
<Data Name="BiosInitDuration">481</Data>
<Data Name="HiberWriteDuration">23241</Data>
<Data Name="HiberReadDuration">0</Data>
<Data Name="HiberPagesWritten">0</Data>
<Data Name="Attributes">20499</Data>
<Data Name="TargetState">4</Data>
<Data Name="EffectiveState">5</Data>
<Data Name="WakeSourceType">4</Data>
<Data Name="WakeSourceTextLength">17</Data>
<Data Name="WakeSourceText">ACPI Sleep Button</Data>
</EventData>
</Event>

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
 

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