Windows 2000磁盘碎片整理脚本
如果你懒地多动几下手,可以使用以下这段“智能”的碎片整理脚本
它将会自动地整理所有的本地驱动器,而不管他们有几个。将以下这段脚
本保存成 DEFRAG.VBS 文件,就可以手动执行或让计划任务去执行了。这
段脚本来自于 Winmag.com
Dim NumDrives, FSO, Drives, Count
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Drives = FSO.Drives
NumDrives = Drives.Count
NumDrives = NumDrives - NumDrives
Const DriveTypeFixed = 2
Const DriveTypeNetwork = 3
For Each Drive in Drives
If Drive.DriveType = DriveTypeFixed then NumDrives = NumDrives
+ 1
Next
Set Drives = Nothing
Set FSO = Nothing
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "dfrg.msc"
WScript.Sleep 2000
While WshShell.AppActivate("Disk Defragmenter") = FALSE
wscript.sleep 1000
WshShell.AppActivate "Disk Defragmenter"
Wend
do while (Count <= NumDrives)
wscript.sleep 200
WshShell.SendKeys "%A"
wscript.sleep 200
WshShell.SendKeys "D"
While WshShell.AppActivate("Defragmentation
Complete") = FALSE
wscript.sleep 5000
Wend
WshShell.AppActivate "Defragmentation
Complete"
wscript.sleep 200
WshShell.Sendkeys "{RIGHT}"
wscript.sleep 200
WshShell.SendKeys "{ENTER}"
wscript.sleep 500
WshShell.Sendkeys "{DOWN}"
Count = Count + 1
loop
WshShell.Sendkeys "%{F4}"