Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automate xp defrag

Status
Not open for further replies.

mickyjune26

Technical User
Mar 26, 2002
270
US
Is there anyway to automate defrag on XP machines?
(How about scandisk?)
Thanks in advance!
 
It might be a bit hard as those two utilities sometimes need sole access to the drive to perform properly. ChkDsk likes to run before you start windows, and Defrag will only half do the job if other applications are running.

To find out about scheduling tasks type ....Scheduled Tasks overview....in the Help and Support program and follow the related links.
 
Well to schedule defrag, you might need to pick up disk keeper for Executive software.. (not a plug, I use the Lite version)

 
You can not schedule a defrag but...

You can defrag using a VB script and schedule that. The script below was written by Doug Knox, a MSMVP that frequents the MS newsgroups. I haven't figured out how to format these posts quite right, so I hope this works correctly. Copy & paste the text below (not including) the horizontal line into notepad and save it as defrag_all.vbs

--------------------------------------------------------
'defrag_all.vbs - Defrags all hard disks - Can be run as a Scheduled Task
'© Doug Knox - 3/29/2002
'This code may be freely distributed/modified

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing
 
Also see Diskeeper Lite, a free version, 9.77 MB download.

Dave Y
 
Try creating a batch file (Defrag.bat) in a folder on C: root with the following lines:

Defrag C: /V
Defrag D: /V

... and so on depending on how many drives you need to defragment. Create a scheduled task from this batch file. I have been using this task for a couple of months and it works just fine (runs at 3:00 AM).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top