PDA

View Full Version : Windows XP Defrag



Sam H
14-07-2002, 02:32 PM
After reading the article in the june issue of PC World 'Tools for trouble free computing. I noticed that Windows XP Disk defragmenter did not have a built in scheduler. I set about finding a way to schedule it and came up with this.

Go to Start, Programs, Accessories, System tools then right click the
disk defragmenter, select send to desktop (create shortcut). Open the scheduled tasks in the control panel and drag and drop the shortcut into there. You then Right click the task to schedule it when you want it.

For those that wanted to know how, then this is how I scheduled it. It automatically scheduled it for a weekly defrag.

Just wanting to know if robo, Bruce or another IDG worker could find out if that was the way that they did it in the article.

Babe Ruth
14-07-2002, 02:42 PM
sam H,

There's no problem regarding scheduling defrag, but what happens when it actually runs?

Babe.

godfather
14-07-2002, 02:44 PM
exactly, it might strike problems with processes running..

Sam H
14-07-2002, 02:50 PM
Okay I didn't think of that

*back to the drawing board*

Babe Ruth
14-07-2002, 02:52 PM
Sam H,

Soryy about that I clicked post instead of preview.

There's no problem regarding scheduling defrag, but what happens when it actually runs? How do you get the defrag options. Without a window it ain't gonna work.

You would need to create a batch job using the command line paramters for DEFRAG and schedule that batch job

defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text

e.g. for each drive/partition have a line in the cmd file
defrag {DRIVELETTER}: -f -v

or
have multiple scheduled jobs in the scheduler e.g.
C:\WINDOWS\system32\defrag.exe c: -f -v
C:\WINDOWS\system32\defrag.exe d: -f -v
C:\WINDOWS\system32\defrag.exe f: -f -v

Also schedule the job(s) using an Administrative user.

Cheers, Babe.

Babe Ruth
14-07-2002, 03:25 PM
Running DEFRAG on Windows XP Pro / Home - must be run as an Administrator user

Example using the command line to run a defrag on drive G: immediately and the otuput:

$> defrag g: -f -v
Windows Disk Defragmenter
Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.

Analysis Report

Volume size = 4.24 GB
Cluster size = 4 KB
Used space = 2.65 GB
Free space = 1.59 GB
Percent free space = 37 %

Volume fragmentation
Total fragmentation = 17 %
File fragmentation = 34 %
Free space fragmentation = 0 %

File fragmentation
Total files = 9,124
Average file size = 316 KB
Total fragmented files = 92
Total excess fragments = 768
Average fragments per file = 1.08

Pagefile fragmentation
Pagefile size = 0 bytes
Total fragments = 0

Folder fragmentation
Total folders = 627
Fragmented folders = 3
Excess folder fragments = 3

Master File Table (MFT) fragmentation
Total MFT size = 19 MB
MFT record count = 9,776
Percent MFT in use = 49
Total MFT fragments = 2



Defragmentation Report

Volume size = 4.24 GB
Cluster size = 4 KB
Used space = 2.65 GB
Free space = 1.59 GB
Percent free space = 37 %

Volume fragmentation
Total fragmentation = 0 %
File fragmentation = 0 %
Free space fragmentation = 0 %

File fragmentation
Total files = 9,124
Average file size = 316 KB
Total fragmented files = 0
Total excess fragments = 0
Average fragments per file = 1.00

Pagefile fragmentation
Pagefile size = 0 bytes
Total fragments = 0

Folder fragmentation
Total folders = 627
Fragmented folders = 1
Excess folder fragments = 0

Master File Table (MFT) fragmentation
Total MFT size = 19 MB
MFT record count = 9,776
Percent MFT in use = 49
Total MFT fragments = 2


Example of using the AT command to schedule a defrag job on disk G: every week on a friday at 10:00pm with a logfile written to C:\Defrag_G.log

$> at 22:00 /every:f """cmd /c defrag g: -f -v > C:\defrag_g.log"""

To see the submitted job use the AT command with no parameters

$> AT
Status ID Day Time Command Line
--------------------------------------------------------------------------------------------
1 Each F 10:00 PM "cmd /c defrag g: -f -v > C:\defrag_g.log"

What are the DEFRAG and AT command parameters:

$> defrag /?
Usage:
defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text

$> AT /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

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.


If any of this is helpful to you good. If not ...

Cheers, Babe.

Sam H
14-07-2002, 04:55 PM
Cheers for the info Babe Ruth.