Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 use PageDefrag to keep my page-file healthy, and have it set to run at every boot with a 1sec timeout. I think it would be really handy to be able to defrag the rest of my machine every-time I tell my machine to shut-down (not restart). If it could activate after windows has killed all the background processes and provide a little information on it's progress it would be very useful.

Is there anything that can do this, or is there a way I can "hook" a batch file/command into the shut-down process to run "defrag.exe"?

Please Note: I'm not looking for something that can defrag then shutdown, but rather initiate the shutdown procedure (to close all running/background apps) and then pause the shutdown to run the defrag while there are no locked files.

share|improve this question
For whatever solution you find: ensure it doesn't interfere with Windows Update, which sometimes runs during shutdown as well? – Arjan Feb 23 '10 at 10:53

I use O&O Defrag and it can do the equivalent: it can shutdown the computer after having run the boot-time defragmentation.

share|improve this answer

You could write a Batch-File which is running f.e. MyDefrag and shuts down the machine afterwards, like this:

C:\PathToMyDefrag\MyDefrag.exe -r "yourSxriptHere"
shutdown -s -f -t 00

The MyDefrag-Script does need the following line it:

share|improve this answer

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.