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”

image

The data source can be set empty:

image

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:

image

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

image

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

image

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

image

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

image image

email

Written by , Posted .