How to schedule a task to run when shutting down windows
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
- Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
- User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add