none
Rodar defrag no 2000Server RRS feed

  • Pergunta

  • Bom dia Srs,
    Preciso de um script que rode o defrag no 2000 server, pois temos 50 servers e queremos automatizar o processo
    Achei muitos prontos na net mas todos voltado para XP/2003 onde fazem uso da linha de comando, não disponivel no 2000

    Anderson Hoffmann
    quinta-feira, 5 de outubro de 2006 13:21

Respostas

  • Bom dia,

    Encontrei esse VBS na net, só não tive como testar.

     

    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

     

    Caso considere a resposta satisfatória não esqueça de classifica-la.

     

    Obrigado,

    quinta-feira, 5 de outubro de 2006 14:23

Todas as Respostas

  • Bom dia,

    Encontrei esse VBS na net, só não tive como testar.

     

    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

     

    Caso considere a resposta satisfatória não esqueça de classifica-la.

     

    Obrigado,

    quinta-feira, 5 de outubro de 2006 14:23
  • Obrigado Bruno..

    Eu já havia pego este script na net. mas não havia funcionado..
    Mas agora eu sei o porquê!!!
    É só alterar as palavras Disk Defragmenter por Desfragmentador de disco e Defragmentation Complete por Desfragmentação concluída, pois meus Windows são em Portugues-BR

    Resolvido..
    Abraços,
    Anderson Hoffmann
    sábado, 7 de outubro de 2006 22:34
  • Olá pessoal, td bem com vcs?

    Bom achei extremamente útil o script em questão, porém não consigo rodar o script, para que o mesmo rode na proxima unidade, na qual seria a D:\, alguém sabe me dizer como faço para que o script mencionado acima, rode na próxima unidade?

    Agradeço, desde já, pela atenção despendida.

    Atenciosamente,

    Junior
    quarta-feira, 29 de novembro de 2006 02:24
  • cara testei aqui e precisa por na linha em que esta esse comando

    WshShell.Run "dfrg.msc"

    alterar para

    WshShell.Run "dfrg.msc d:"

    ve se funciona

    abraços

    quarta-feira, 29 de novembro de 2006 11:38
  • Ola rkanopka, bom dia!

    Funcionou, muito obrigado.

    Atenciosamente,

    Junior
    quarta-feira, 29 de novembro de 2006 13:17