Scheduling A Weekly Defrag Through SMS/ConfigMgr

Without any third party tools here is a simple way to create a weekly defrag task on your client workstations. This is specific for Windows XP, although you could create something similar for Vista or Windows 7.

We went to create a new Package called “Schedule Weekly Defrag”


The data source can be set empty:


Then we want to create a new program called “Schedule Defrag Task”

This is your command line, this one will run every Sunday at 8 AM and defrag the C drive:

schtasks.exe /create /sc weekly /d SUN /tn defrag /tr "c:\windows\system32\defrag.exe c: -f" /st 08:00:00 /sd 01/20/2007 /ru "system"

Notice we set the start path, and make sure to set it to run hidden:


For the Environment, we want admin context and we will need a drive letter for the command to execute:


It’s also my preference to hide notifications, since this is administrative task:


Here we can see the task has been created on a client machine:


If we look at the actual task, we can see the properties are set correctly:

image image


Written by , Posted .

Leave a Comment

You must be logged in to post a comment.