Server Fault is a question and answer site for system and network administrators. 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

I have been looking for a way to run a batch script(just a single 'del' command) whenever the system shutdowns or reboots. The system is running a Windows XP Professional with Service Pack 2.

share|improve this question
up vote 7 down vote accepted

You can define a shutdown script from within the group policy editor (Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts).

share|improve this answer
+1. I use the startup/shutdown script on all servers (via GPO) to have an email sent when a machine is shutting down, and has then booted back up, on top of monitoring, just in case the reboot is too quick for Nagios to catch it. Handy. (Although I'd love it if it didn't matter which servers were shut down :) – Cawflands Jul 18 '09 at 8:28

You can use scheduled tasks to run a command at system start or user log on.

share|improve this answer
Does not cover shutdown/logoff. – Richard Jul 18 '09 at 9:04
But can be combined with the other approach. – Joey Jul 18 '09 at 13:37

Your Answer


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.