On Windows XP, it's simple. Just run this command and you are done:

schtasks /create /TN defrag /RU "NT AUTHORITY\SYSTEM" /SC weekly /TR "defrag %systemdrive%"