Autoclose defrag when done?

Pastore

Diamond Member
Feb 9, 2000
9,728
0
76
Is there any easy way to close a defrag when done, with some type of command or operator somewhere? I have defrag scheduled to run sat. evenings at the office on about 45 machines, but users complain because there is a defrag window monday morning when they come in. I could write a small app to run in the background but that would just eat up more cycles, and scheduling a new task to run a batch file to close it would take a while to implement. Any other ideas?
 

Rapidskies

Golden Member
May 27, 2003
1,165
0
0
My first thought would be to schedule the computers to reboot or shutdown after the defrag, whichever you prefer. You would be replacing the defrag window with a logon prompt for "security purposes". Also you could write a script to close the app and have it run after the defrag as another option. Both would require touching the machines though to set it up.

I found this sample script: Scheduling Defrag Via Script

'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

'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
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

'Send and ALT-F4 to Close the Defrag program
WshShell.Sendkeys "%{F4}"
 

Pastore

Diamond Member
Feb 9, 2000
9,728
0
76
Yeah touching the machines is a problem considering my hours are very inflexible and they are all being used while I'm here. I have it setup on the XP machines using the defrag.exe command line utility, and that runs in a system window which I "think" closes automatically when done, but the 2000 machines run the gui defrag utility and can't find a way to run it in the command line in 2000 so I can set it up as a task.
 

Pastore

Diamond Member
Feb 9, 2000
9,728
0
76
ahhh excellent, thanks for that script. I got that running and now I can run it as a sceduled task on the remote machines. Thanks again.
 

cKGunslinger

Lifer
Nov 29, 1999
16,408
57
91
I have a batch file that I use to silently defrag all my drives/partitions once a month in the wee hours of the AM. This is for an XP machine, but I thought that I had been using this batch file for years, even with Win2K, but perhaps not.

Your best bet is probably that script written above, but you could also check into this.