Submitted by: Rain
Code: Select all
//Set If d.DriveType = to " 1 Then" to
//defrag all Removable drives
//Set If d.DriveType = to " 2 Then" to
//defrag all Fixed drives
//Set If d.DriveType = to " 2 OR 1 Then" to
//defrag all Fixed and Removable drives
VBSTART
Set WshShell = 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 & " -f", 1, TRUE)
End If
Next
Set WshShell = Nothing
VBEND