5
1
Possible Duplicate:
Is there a way to execute a program on power events?
Is there a Windows event that I can watch in Task Scheduler that will trigger when the power is plugged in? And an event when the power is unplugged?
I want to start and stop CrashPlan while on battery power. (This has been a 2.5-year-old feature request in CrashPlan and honestly I can't wait for them to add it.)
Others have also asked previously how to disable SuperFetch and Search Indexing on battery power. I think this trick will solve these questions, too.
Is there such a windows event? If not, could there be a program that I can install that detects power changes, which then I can create a Task Scheduler trigger for.
If the only event OP wants to capture is a change in the AC charger status through the Win32 API, he can simply handle PBT_APMPOWERSTATUSCHANGE events through the SERVICE_CONTROL_POWEREVENT control code in the HandlerEx callback to RegisterServiceCtrlHandlerEx, or the WM_POWERBROADCAST message in WindowProc. This should be supported by Windows XP and later. However, he asked for an Windows Event. – Kevin Jin – 2017-09-03T21:37:39.840