Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to run a .bat or .cmd when the screensaver starts? I've noticed some .exe can run if you rename them to .scr but is that it?

share|improve this question
    
This isn't a direct answer, but, a screen saver stars typically after N amount of idle time. You could use task scheduler to wait for the same amount of time and then launch your program? –  Dave Jan 18 '13 at 11:45
    
Nah, task scheduler has a whole different idea of what 'idle' is, if I remember correctly, it looks for CPU idle time among other things. –  laggingreflex Jan 18 '13 at 14:48
    
Maybe creating a task in the Task Scheduler with a Trigger of “On workstation lock” would work. Conditions of “Start the task only if the computer is idle” and “Stop if the computer ceases to be idle” might give you what you want. –  Scott Jan 18 '13 at 21:12

2 Answers 2

up vote 8 down vote accepted

1. Screen Launcher

Screen Launcher lets you choose any program to run as a screensaver. You could start a Powerpoint, a movie or any EXE or associated file. To install, simply unzip, right-click and click Install on the context menu. You can then use Screen Launcher just like any other screensaver. To open files such as Powerpoint presentations, you must execute the powerpoint program and type the path to your ppt as a parameter. An example for displaying an image would be c:\winnt\system32\mspaint.exe c:\picture.bmp. Download today to take advantage of any media as a screensaver.

1

2. RunSaver

Screensaver that runs a command.

2

I'm sure there are many more such screensavers that will allow you to launch arbitrary programs/scripts. But what if you'd like to continue using your current screensaver? If so, see below for the solution (tested on Win7, should work fine on Vista+).


3. Using no 3rd party tools

  1. Event ID 4802 corresponds to The screen saver was invoked, but it is not logged by default and thus we need to enable logging for this event first. So open the Local Group Policy Editor (Start / Run / gpedit.msc), navigate to:

    Computer Configuration / Windows Settings / Security Settings / Advanced Audit Policy Configuration / System Audit Policies - Local Group Policy Object / Logon/Logoff / Audit Other Logon/Logoff Events

    and enable the checkboxes for Success and Failure:

    3

  2. If you wait for your screensaver to be launched, you'll now see event logs similar to the following in Event Viewer:

    4

  3. Now it's easy to use Task Scheduler to create a task that will be launched when Event 4802 occurs. Just ensure that the Triggers tab of the task's Properties dialog looks like the following:

    5
    6

share|improve this answer
    
You deserve a medal –  Prof Pickle Mar 10 '13 at 0:50
    
@ProfPickle: Thank you for your kind words. :) –  Karan Mar 10 '13 at 1:16

If time is not terribly critical, then you could simply use the Task Scheduler's built-in Trigger "Begin the task: On Idle".

Task Scheduler -> Create Task -> "Trigger" tab -> New -> "Begin the task:" -> "On Idle"

Next, go to the "Actions" tab and set the action to whatever it is you want to run.

This should execute the Action after the screensaver starts (or if the system goes idle without the screensaver), but there may be a 0-15 minute delay. Here is the relevant specifics from the Task Scheduler documentation:

The Task Scheduler service will check if the computer is in an idle state every 15 minutes. A computer is considered to be in an idle state when a screen saver is running. If a screen saver is not running, then the computer is considered to be in an idle state if there is 0% CPU usage and 0% disk input or output for 90% of the past fifteen minutes and if there is no keyboard or mouse input during this period of time.

So, your screensaver launches, and then 0-15 minutes later windows checks for idle and launches your program.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.