Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Run scheduled task or a GPO when Win7 SleepMode is triggered?


09 Jul 2012   #1

Windows 7 Ultimate x64
 
 
Run scheduled task or a GPO when Win7 SleepMode is triggered?

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.

Does anyone know of a way to do this?

My System SpecsSystem Spec
.

09 Jul 2012   #2

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Does your task need to run before going to Sleep, or would it be ok to run it on Wakeup?
My System SpecsSystem Spec
09 Jul 2012   #3

Windows 7 Ultimate x64
 
 

Thanks for the quick response!

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.
My System SpecsSystem Spec
.


12 Jul 2012   #4

Windows 7 Ultimate x64
 
 

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.
My System SpecsSystem Spec
12 Jul 2012   #5

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Hi idecz,

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.
My System SpecsSystem Spec
Reply

 Run scheduled task or a GPO when Win7 SleepMode is triggered?




Thread Tools



Similar help and support threads for2: Run scheduled task or a GPO when Win7 SleepMode is triggered?
Thread Forum
Scheduled Task history indicates task completed successfully but.... Performance & Maintenance
eruNT lives again, on Win7/Vista -- without 'Scheduled Task' UAC-hack Backup and Restore
setting up a scheduled task General Discussion
Event triggered task Hardware & Devices
Scheduled task does not run General Discussion
Scheduled task problems Performance & Maintenance
Scheduled Task revisit... General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:38 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33