Once this script is saved as a VBS File… How do you
schedule it? I tried using Task Scheduler and it will not run…
Thanks
Dennis Christilaw
AT&T
Wireless - IT - National Billing & Roaming
3G Mediation Technical
Support Analyst
-----Original
Message-----
From: David Lee
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 07, 2002 2:15
PM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir]
Automating Defragmentation
This is what
I use in VBScript.
'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
WshShell.Sendkeys
"{TAB}"
Wscript.Sleep
500
wshshell.Sendkeys
"{down}"
Wscript.Sleep
500
'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
'WshShell.Sendkeys
"{TAB}"
'Wscript.Sleep
500
wshshell.Sendkeys
"{down}"
Wscript.Sleep
500
'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}"
At 04:04 PM 5/7/2002 -0400, you wrote:
Does any have a script or a source they
can point me to help me Automate
Windows 2000's Defrag utility
Joshua Morgan
PROFITLAB
Senior Network Engineer
PH: (864) 250-1350 Ext 133
Fax: (413) 581-4936
[EMAIL PROTECTED]
http://www.profit-lab.com
http://ncontrol.info
The greatest glory is not in never failing, but in rising up every time we
fall.
-- Confucius
List info : http://www.activedir.org/mail_list.htm
List FAQ : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
David D. Lee
Computer Resource Specialist II
Office of Undergraduate Admissions
[EMAIL PROTECTED]
2-6417