How to start a program as soon as the computer is idle?

16,647

I know this question is old but this is directed at anyone else that might benefit.

I found a pretty good answer to the first question over here: https://superuser.com/questions/777488/task-scheduler-what-is-wait-for-idle-for

Although I still barely understand it as well, and so far I haven't had any luck getting the "Start when idle" condition to actually work. It seems like it's intended be used in conjunction with another timed condition.

Like you, I wanted to run a program the moment the screensaver started or stopped (I assume that's what you mean by idle), and this is the only way I found to do it so far, although it's something of a hack: You can replace the screensaver executable with your own .exe (or .scr) that runs your command and then runs the actual screensaver (or runs your command when it ends).

The path to the current screensaver exe is under: HKEY_CURRENT_USER\Control Panel\Desktop\SCRNSAVE.EXE

You can make a batch file like:

start "" C:\MyStartProgram.exe
C:\Windows\system32\PhotoScreensaver.scr /s
C:\MyEndProgram.exe

If you don't "start" the screensaver then it will block until you interrupt it, and then run the end program. And the /s is so it will start the screensaver rather than open it's configuration dialog (which is also /c, I think).

Then convert that batch into an .exe using a batch-to-exe tool like this, which works and seems to be clean. Then rename the .exe extension to .scr and set that as the SCRNSAVE.EXE registry key I said above (which, remember, will get reset whenever you change any ss options in control panel).

Hope that helps anyone.

Share:
16,647
user2433494
Author by

user2433494

Updated on June 04, 2022

Comments

  • user2433494
    user2433494 almost 2 years

    I'm creating a new task via the 'Task Scheduler' in Windows 7, that starts a program only when the computer is idle.

    When creating a task there are 2 criteria that I want to use:

    • "Start the task only if the computer is idle for:"
    • "Wait for idle for:"

    However, it appears that "in Windows 7, the Task Scheduler verifies that the computer is in an idle state every 15 minutes." (can see it here: link)

    My questions are:

    1. How these criteria above even matter now that we know that it should take minimum 15 minutes? Could someone make a sense from all of this?

    2. How can I create my task to execute a program AS SOON AS THE COMPUTER IS IDLE?

  • user2433494
    user2433494 almost 11 years
    Thank you for your comment, however I already know this info, and it didn't answer my specific questions...