'========================================================================================= ' defrag.vbs ' ' This script runs the Windows defrag utility on each fixed disk attached to the system. ' ' Setup a Scheduled Task to call this script to automate disk defrag. ' ' Copyright 2008 GARA Systems, Inc. ' ' This program is free software; you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation; either version 2 of the License, or ' (at your option) any later version. ' ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' ' http://www.gnu.org/licenses/gpl.html ' '========================================================================================= Set objWShell = WScript.CreateObject("WScript.Shell") Dim objFSO, objDrive, colDrives Set objFSO = CreateObject("Scripting.FileSystemObject") Set colDrives = objFSO.Drives For Each objDrive in colDrives If objDrive.DriveType = 2 Then Return = objWShell.Run("defrag " & objDrive, 1, TRUE) End If Next Set objWShell = Nothing