Command Prompt Tweaks - Scheduling Defrag via the Command Prompt

In this tweak I will show you how to defrag from the command prompt, it's simple and requires no batch file.

  1. Open the Command Prompt with Start -> All Programs -> Accessories -> Command Prompt.
     
  2. Now type at /? then enter and were presented with these options:

    AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
    AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"
     
    • \\computername Specifies a remote computer. Commands are scheduled on the local computer if this parameter is omitted.
    • id Is an identification number assigned to a scheduled command.
    • /delete Cancels a scheduled command. If id is omitted, all the scheduled commands on the computer are canceled.
    • /yes Used with cancel all jobs command when no further confirmation is desired.
    • time Specifies the time when command is to run.
    • /interactive Allows the job to interact with the desktop of the user who is logged on at the time the job runs.
    • /every:date[,...] Runs the command on each specified day(s) of the week or month. If date is omitted, the current day of the month is assumed.
    • /next:date[,...] Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, the current day of the month is assumed.
    • "command" Is the Windows NT command, or batch program to be run.
       
  3. I want to defrag my hard drive c: on Monday, Wednesday, and Friday at 11 p.m. and keep it interactive. (allows visual progress).

    C:\>at 23:00 /interactive /every:M,W,F defrag c:

    and I'm presented with:

    C:\Documents and Settings\XPUSER>at 23:00 /interactive /every:M,W,F defrag c:
    Added a new job with job ID = 1
     
  4. To list your scheduled jobs, just type at at the prompt, then enter:

    C:\Documents and Settings\horstl>at
    Status ID Day Time Command Line
    ------------------------------------------------------------------
    1 Each M W F 11:00 PM defrag c:

    To delete pending jobs, just follow the syntax:

    /delete Cancel a scheduled command. If id is omitted, all the scheduled commands on the computer are canceled.

    So to cancel my job with ID 1:

    at 1 /delete

Author:

Lex van der Horst

Date Added:

15-03-2004

Last Reviewed:

29-09-2004