Dieser Script Defragmentiert alle Fesplatten eines Computers automatisch. Auf Wunsch kann man das auch mehrmals tun.
Am Ende der Defragmentation kann Windows heruntergefahren werden.
Funktioniert mit GUI und Kommandozeile.
Kommandozeilenbefehle:
/S Windows wird am Ende der Defragmentation heruntergefahren
/C x Festplatten werden xmal defragmentiert
#NoTrayIcon
#include <GuiConstants.au3>
Dim $shd=0,$count=1,$while=0
$ok=0
If $cmdline[0]>0 Then
$ok=1
While $while<$cmdline[0]
$while=$while+1
$cmd=$cmdline[$while]
If $cmd='-s' Or $cmd='-S'Or $cmd='/s' Or $cmd='/S' Then $shd=1
If $cmd='-c' Or $cmd='-C' Or $cmd='/c' Or $cmd='/C' Then
$while=$while+1
$cmd=$cmdline[$while]
If $cmd>0 Then $count=$cmd
EndIf
WEnd
Else
$window=GuiCreate('DefragAll',330,90,(@DesktopWidth-191)/2,(@DesktopHeight-70)/2)
GuiCtrlCreateLabel('Soll Windows nach Defragmentation heruntergefahren werden?',5,29)
$guishd=GuiCtrlCreateCheckbox('',310,27,200,20)
GuiCtrlCreateLabel('Wie viel mal sollen die festplatten defragmentiert werden?',5,9)
$guicount=GuiCtrlCreateInput('1',282,5,40,20)
GuiCtrlCreateUpDown(-1)
$button1=GUICtrlCreateButton('Start',5,50,85,25)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button1
$shd = GUICtrlRead($guishd)
If $count<GUICtrlRead($guicount) Then $count=GUICtrlRead($guicount)
$ok=1
GUIDelete($window)
ExitLoop
EndSelect
WEnd
EndIf
If $ok=1 Then
$while=0
$percent=0
$Drives=DriveGetDrive('FIXED')
If @error Then
MsgBox(16,"ERROR","ERROR")
Exit
EndIf
ProgressOn('','','',0,0)
While $while<$count
$while=$while+1
For $i = 1 to $drives[0]
ProgressSet($percent, $i & ' Laufwerke von ' & $drives[0] & ' ' & '( ' & $drives[$i] & ' )' & @CRLF & $while & ' mal von ' & $count)
$percent=$percent+100/$count/$drives[0]
RunWait('defrag.exe ' & $drives[$i],'',@SW_HIDE)
Next
WEnd
ProgressSet($percent,'Fertig')
sleep(1000)
ProgressOff()
If $shd=1 Then Shutdown(5)
Else
Exit
EndIf