Freigeben über


scheduled automatic defrag of your hard-drive

This isn't that big of a deal, but since some articles make it sound like this is a difficult thing, I wanted to post something others may find helpful in getting automatic defrag going.

Adi (among many others) had posted a schtasks.exe call that will get defrag running weekly but it doesn't specify the day of the week or the time of day (both default to current), so I'd change it based on that.  Since 4am on Sunday is reasonable (and the default in the current Vista builds), we'll go with that.

I'm sure adding the .exe extensions seems a little odd, but I'm getting into that habit mainly because of "sc" in powershell being an alias for set-content, so my usual calls to sc.exe need to be spelled out (I don't mind strongly enough to remove the alias from all the different machines I use).

This will need to be run as an administrator, but given the nature of defrag, I hope that doesn't come as a surprise.  Also, you may have more than one logical drive (I have both C: and D: on my main machine at work, for instance), but creating a second (or third) scheduled task for defrag'ing the other drive(s) should be pretty straightforward.

schtasks.exe /create /tn defrag /ru system /sc weekly /d sun /st 04:00 /tr "defrag.exe %systemdrive%"

Comments