Jump to content

PriTyan

Member
  • Posts

    1
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About PriTyan

PriTyan's Achievements

0

Reputation

  1. I have a VBScript that I have been running for a while on my 2000 Servers to automate Disk Defrag. This works great on 2000 Servers. See code below 'Automate Defrag for Windows 2000 Dim Window, sysd, cmd set Window = CreateObject("WScript.Shell") sysd = Window.ExpandEnvironmentStrings("%defdrive%") cmd = "dfrg.msc %" & sysd Window.Run cmd WScript.Sleep 1000 While Window.AppActivate("Disk Defragmenter") = FALSE wscript.sleep 1000 Wend Window.AppActivate "Disk Defragmenter" WScript.Sleep 1000 Window.SendKeys "%A" WScript.Sleep 250 Window.SendKeys "D" WScript.Sleep 250 While Window.AppActivate("Defragmentation Complete") = FALSE wscript.sleep 5000 Wend Window.AppActivate "Defragmentation Complete" WScript.Sleep 250 Window.Sendkeys "{TAB}" WScript.Sleep 250 Window.Sendkeys "{ENTER}" WScript.Sleep 250 Window.Sendkeys "%{F4}" WScript.Sleep 250 WScript.Quit Here is my problem on 2003 Servers. The below code waits for the pop-up window titled "Defragmentation Complete" to identify that the defrag has completed, then the rest of the code procedes to send keys to close out of defrag. While Window.AppActivate("Defragmentation Complete") = FALSE wscript.sleep 5000 Wend The problem with 2003 defrag is that the title to the pop-up window that indicates Defrag has completes is the same as that Defrag app "Disk Defragmenter". So my problem is how do I identify the new pop-up window since it has the same name as the original window? See image below. I've contiplated just putting a long Sleep command, but would like my code to be a little cleaner. Any help would be appreciated. P
×
×
  • Create New...