Hello all, I'd like to launch a custom batch file when my computer goes into sleep mode. I would like to launch this batch through a GPO or task scheduler.
I've tested using task scheduler and the power event ID for sleep mode but it seems the event triggers too late for the application to run and the computer just continues into sleep mode.
I could create a scheduled task to trigger a minute before the idle time-out for sleep mode but this doesn't help if I actively put the computer into sleep mode.
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.
Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.
Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
The task needs to run before the machine sleeps. I'm going to test creating the task on system lock and see if it triggers while going into sleep mode.
On second thought, I actually don't want this batch file to run during lock but only when entering sleep-mode.
Okay through testing I've discovered that using the event id for sleep-mode won't work because it is triggered too late for task scheduler, in fact task scheduler will read the event id after waking up and then trigger.
I was able to get task scheduler to trigger before sleep-mode based on idle timeout but this doesn't help when a user actively enters sleep-mode.
Going to check around on technet and try some experimenting.
It sounds like you know what you are doing and why.
I'm following this to learn from you
I wondered if the task would start after the wake-up, and you answered that with
"will read the event id after waking up and then trigger".
Can I ask, why do you need the task to run before sleep?
I'm a programmer, so i can understand there is a need ... disconnect from resources, logoff network accounts, kill a kiosc session, ... etc.
I'm just wondering if there might not be a better/easier/safer way to do what you need to do than using task scheduler.
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.
Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.
Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.