Set WshShell = WScript.CreateObject("WScript.Shell")

Dim FileObjects, Drive, dc, DefragLog
DefragLog = "c:\defrag.txt"

Set FileObjects = CreateObject("Scripting.FileSystemObject")
Set HDD = FileObjects.Drives


For Each Drive in HDD
	If Drive.DriveType = 2 Then
		RunString = "%comspec% /c %WINDIR%\System32\Defrag.exe " & Drive & " -a"
		Return = WshShell.Run(RunString & " >> " & DefragLog & " 2>&1", 0, TRUE)
		Set WshShell = Nothing
	End If
Next