Defrag Script for all Fixed Disks
Defragging your system is an EXTREMELY important thing to do. A slow performing disk is the number one killer of overall system performance. In my opinion a ”slow” machine is due to POOR disk performance.
DON’T LET THIS HAPPEN TO YOU!!!
‘Mark Torng DEFRAG all fixed disks with VBScript
Const LogFile = “C:\Defrag.log”
Const DriveTypeRemovable = 1
Const DriveTypeFixed = 2
Const DriveTypeNetwork = 3
Const DriveTypeCDROM = 4
Const DriveTypeRAMDisk = 5
Set FSO = CreateObject(“Scripting.FileSystemObject”)
Set Drives = FSO.Drives
For each Drive in Drives
if Drive.DriveType = 2 then
RunCmd Drive
end if
Next
Sub RunCmd(DriveString)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
RunString = “%comspec% /c echo ” & WeekDayName(WeekDay(Now), True) & ” ” & Now & ” ” & DriveString
Return = WshShell.Run(RunString & ” >> ” & LogFile & ” 2>&1″, 0, TRUE)
RunString = “%comspec% /c %WINDIR%\System32\Defrag.exe ” & DriveString & ” -f”
Return = WshShell.Run(RunString & ” >> ” & LogFile & ” 2>&1″, 0, TRUE)
Set WshShell = Nothing
End Sub
As always, you must use the visual basic script extention.
Copy the above, paste into a notepad, and save the file as whateveryouwant.vbs



