DefragAll

  • 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

    [autoit]


    #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

    [/autoit]

    Einmal editiert, zuletzt von Filin (10. April 2007 um 23:21)

  • warum kann ich bei der Anzahl der Durchläufe negative Zahlen einstellen o.O??
    Vllt. ist auch die Formulierug: Wie oft besser als wie viele mal

  • So jetzt darf man nur positive Zahlen eingeben und statt "wieviel mal" steht "wie oft".

    Spoiler anzeigen
    [autoit]


    #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 oft sollen die Festplatten defragmentiert werden?',5,9)
    $guicount=GuiCtrlCreateInput('1',282,5,40,20,0x2000)
    GuiCtrlCreateUpDown(-1)
    $button1=GUICtrlCreateButton('Start',5,50,85,25)
    GuiSetState()
    While 1
    If GUICtrlRead($guicount)<1 Then GUICtrlSetData($guicount,1)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $button1
    $shd = GUICtrlRead($guishd)
    $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

    [/autoit]
  • /off topic

    Zitat

    Original von huggy
    | off topic: was steht da denn? :)

    Zitat

    Original von BugFix
    \off topic
    Dein Avatar gefällt mir: "Meister der idiotischen Kommentare" :D

    5 Mal editiert, zuletzt von Filin (11. April 2007 um 22:00)

  • ich habes es mal bei allen Partionen(5) von mir durchlaufen lassen (1mal) und irgendwie bin ich gegangen und hab meinen Rechner alleine gelassen; nur kommt da noch ne Meldung oder schließt sich das von alleine??