theshadow27 said:
i would like to run a script (either a batch file or some other
script) before windows enters "standby" mode. how would i go
about doing that?
Hi
You can use the WMI class Win32_PowerManagementEvent to detect a
standby event.
Try the vbscript below and see what you get as result (put it in a
file with .vbs as file extension name). If it works ok, you can add
code to start an application/batch file depending on the event type.
Win32_PowerManagementEvent WMI class
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_powermanagementevent.asp
A vbscript example (will loop forever until terminated):
'--------------------8<----------------------
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
'--------------------8<----------------------