Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As of writing, the only options available are to "Begin the task":

  • On a schedule
  • At logon
  • At startup
  • On idle
  • On an event
  • At task modification/creation
  • On connect to user session
  • On disconnect from user session
  • On workstation lock
  • On workstation unlock

Is there a way to have Task Scheduler run a task before shutdown?

share|improve this question

You can create shutdown tasks with the Group Policy Editor in Windows 7.

share|improve this answer

Even though this is an older thread, I'd like to add a solution I devised that works well.

I wanted to run a script or batch file whenever a shutdown or restart was initiated, but I didn't want to use Group Policies Shutdown Scripts function. The reason for this was pretty in depth, but I basically needed to run a script before certain services were closed.

I ended up creating a scheduled task as follows:

  • Type : On Event (Basic)
  • Log : System
  • Source : User32
  • EventID : 1074

When a user or command initiates a shutdown or restart as a logged on user or on a user's behalf, event ID 1074 will fire. By creating a task to use this to trigger a script, it will start the script and allow it to finish, however it will only report the task as "running" or "triggered" in the logs. I have not used this with a long script, so it may be worth testing further, but it works great for short scripts.

share|improve this answer

Task Scheduler is limited in its ability to schedule a task at shutdown. A similar question was asked on Stack Overflow (how-to-schedule-a-task-to-run-when-shutting-down-windows), and the answers there describe several methods other than using the Task Manager, including the Group Policy Editor method, which is described in detail and might be a better way to handle it.

The Task Scheduler can be used instead of Group Policy Editor. However, it's only good for very short tasks, which will run as long as the system is restarting or shutting down, which is usually only a few seconds.

In addition, please note that the task status can be:

The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)

However, it doesn't mean that it didn't run.

share|improve this answer
This should be posted as a comment instead of an answer as the OP specifically wants to know how to do so using Task Scheduler. You may post comments once you have enough reputation. – Rsya Studios Dec 6 '14 at 2:14
You are right, and I wish I could do it right now since I don't know when and if I'll get enough credit. If it's too problematic please delete my answer and add it as a comment under your name. Although I won't get any recognition, the community will get this information - and that's the first priority :-) – Oz Edri Dec 6 '14 at 2:52
+1 to help you get enough rep, you can post it as a comment once you reach the threshold :) – Rsya Studios Dec 6 '14 at 3:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .