Automatically running a windows bat file after returning from idle

4

1

First off, the background on what I want to do:

I am running rosetta@home on my computers at home and work, and I often find minirosetta tasks stuck in memory when I resume using the computer after a long idle period. I haven't found any real solution to the problem so I am looking for a workaround solution that involves automatically killing the minirosetta tasks when I return from an idle state.

It is possible to kill tasks with a simple command line (in windows7):

taskkill /IM taskname.exe /F

So I am looking for a way to execute a batch script to kill minirosetta tasks when I return from idle mode. Does anyone know if I can use one of the event triggers under windows task scheduler to automatically run a bat file after returning from idle? I see many different possibilities for event triggers but no idea what to use for returning from idle.

Alternatively I could run an executable or bat file when idle, and this executable could wait for mouse/keyboard action before it runs a script to kill the minirosetta tasks. Is this possible with simple scripts or do I need to compile a windows exec?

Thanks

Peter Hahn

Posted 2013-06-30T20:02:32.113

Reputation: 67

Answers

3

I'm assuming when you return after leaving the PC idle for a while you find the screensaver running and dismiss it using the mouse or keyboard. So one possible solution would be to execute your batch file (or even taskkill directly) on screensaver dismissal.

Event ID 4803 corresponds to The screen saver was dismissed, so all you need to do is turn on logging of this event using the Local Group Policy Editor and then use Task Scheduler to create a task that will be launched when the event occurs. You can find a detailed tutorial for this here.

Karan

Posted 2013-06-30T20:02:32.113

Reputation: 51 857

wow, awesome exactly what I was looking for! thank you so much – Peter Hahn – 2013-06-30T22:46:36.227

well, shucks i only have win7 home premium, so cannot run the local group policy editor. is there any registry hack i can do to enable logging of event 4803? – Peter Hahn – 2013-06-30T23:56:37.590

The official docs state that "Audit Policy security settings are not registry keys", and the Group Policy Search site didn't return anything. I think you're out of luck unless this works for you, but I've never tried it.

– Karan – 2013-07-01T00:14:46.870

interesting, thanks again! and i was about to try learning and writing python! maybe i still will, working the win api through python seems like it would be convenient – Peter Hahn – 2013-07-01T00:27:57.423

Did this finally worked? I'm curious because I also want to run a command (to stop an online backup service) once I return to using my computer. – Chuim – 2013-07-13T01:34:33.527

@Chuim: If you have Group Policy Editor there's no reason it won't work. – Karan – 2013-07-13T01:36:35.747

@Karan: thanks for getting back on this and yes it did totally work for me! :) – Chuim – 2014-03-25T14:07:53.843