Auto Defrag

14 Dec

Msgbox(0,"Info by Joe. R","Auto Defrag All Harddisks & Shutdown PC")

If (@OSVersion <> "WIN_XP") AND (@OSVersion <> "WIN_2000") Then
 Msgbox(0,"Info  by X-Guy",@OSVersion & " Not Tested!")
EndIf

BlockInput(1)
Run("defrag.bat")
WinWait("Disk Defragmenter")

$var = DriveGetDrive( "FIXED" )

$bLoop = 0
While $bLoop <> $var[0]

 WinActivate("Disk Defragmenter", "")
 Send("!A")
 Send("d")
 BlockInput(0)

 If @OSVersion == "WIN_XP" Then
  WinWait("Disk Defragmenter", "Defragmentation is complete")
 Else
  WinWait("Defragmentation Complete")
 EndIf

 BlockInput(1)
 If @OSVersion == "WIN_XP" Then
  WinActivate("Disk Defragmenter", "")
 Else
  WinActivate("Defragmentation Complete", "")
  ControlClick("Defragmentation Complete", "", "")
 EndIf
 Send("{TAB}")
 Send("{ENTER}")
 WinActivate("Disk Defragmenter", "")
 ControlSend ( "Disk Defragmenter", "", "SysListView321", "{DOWN}")

 $bLoop = $bLoop + 1
WEnd

WinActivate("Disk Defragmenter", "")
Send("!{F4}")
BlockInput(0)

Shutdown(8)

;0 = Logoff
;1 = Shutdown
;2 = Reboot
;4 = Force
;8 = Power down
;32= Suspend
;64= Hibernate

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: