Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Yeah, that's the option I was thinking of... but how does it stop the defrag? Does it just kill the task, or can it shut down the defrag gracefully?you can tell it to stop after running for X hours however.
'This script launches defrag and sends keys to the UI in
'order to automate the defrag process.
Set WshShell = CreateObject("WScript.Shell")
'Launch Defrag from the command line and wait for a second.
WshShell.Run "dfrg.msc"
WScript.Sleep 1000
'Wait until the application has loaded - Check every second.
While WshShell.AppActivate("Disk Defragmenter") = False
WScript.Sleep 1000
Wend
'Modifications by Alfonsom, fixed/updated by Josh West.
Dim oFSO, oDrives, oDrive, firstjump
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = oFSO.Drives
firstjump = 0
'We use this variable to check if we have jumped first in
'the drive list.
'It is necessary because the key sequence is a bit
'difference in the first jump.
For Each oDrive In oDrives
If oDrive.DriveType = 2 Then
'Bring the application to the foreground.
WshShell.AppActivate "Disk Defragmenter"
WScript.Sleep 200
'Send an ALT-A key to bring down the degrag menu.
WshShell.SendKeys "%A"
WScript.Sleep 200
'Send a D to start the defrag.
WshShell.SendKeys "D"
'Wait until the defrag is completed - Check for window
'every 5 seconds.
While WshShell.AppActivate("Defragmentation Complete") = False
If WshShell.AppActivate("Disk Defragmenter") = False Then
Exit For
End If
WScript.Sleep 5000
Wend
'Bring the msgbox to the foreground.
WshShell.AppActivate "Defragmentation Complete"
WScript.Sleep 200
'Send a tab key to move the focus from View Report button
'to the Close Button.
WshShell.SendKeys "{TAB}"
WScript.Sleep 500
'Send key to Close the Defragmentation Complete window.
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
'Bring the application to the foreground.
WshShell.AppActivate "Disk Defragmenter"
WScript.Sleep 200
'Move down to next drive
If firstjump = 0 Then WshShell.SendKeys "{TAB}{DOWN}"
firstjump = 1
Else: WshShell.SendKeys "{DOWN}"
End If
Next
'Send and ALT-F4 to Close the Defrag program.
If WshShell.AppActivate("Disk Defragmenter") = True Then
WshShell.AppActivate "Disk Defragmenter"
WshShell.SendKeys "%{F4}"
End If
'Send and ALT-F4 to Close the Defrag program.
If WshShell.AppActivate("Disk Defragmenter") = True Then
WshShell.AppActivate "Disk Defragmenter"
WshShell.SendKeys "%{F4}"
End If