schedule defrag to mulitple servers ( schedule task)

Discussion in 'Windows Server' started by mr555, Aug 6, 2009.

  1. mr555

    mr555 Guest

    hi all

    we have 120 windows 2003 servers we would like to schedule a defrag for all
    off them.
    what is the best way to copy a defrag schedule task accros to all 120
    servers, some of the servers in a different domain

    appreciate any advice on this

    Thank you
     
    mr555, Aug 6, 2009
    #1
    1. Advertisements

  2. Hello Mr555,

    Check out this one, on a test machine first, as startup script 'defrag.cmd':

    ;Create the scheduled task on remote machines
    if not exist c:\windows\tasks\at1.job at 05:00 /every:m,t,w,th,f,s,su c:\windows\system32\defrag.exe
    C:


    Best regards

    Meinolf Weber
     
    Meinolf Weber [MVP-DS], Aug 6, 2009
    #2
    1. Advertisements

  3. mr555

    mr555 Guest

    Hi Meinolf

    Thank you so much it works great.



     
    mr555, Aug 6, 2009
    #3
  4. mr555

    mr555 Guest

    Hi Meinolf

    I have another question hope you may he able to help, some servers has D
    drive and some has E and F

    what is the best way to create the addition schedule task for those servers
    that may have more then 1 drive, anyway we can detact before creates ?

    Thanks
     
    mr555, Aug 6, 2009
    #4
  5. Hello Mr555,

    You're welcome.

    Best regards

    Meinolf Weber
     
    Meinolf Weber [MVP-DS], Aug 7, 2009
    #5
  6. Hello Mr555,

    I am not that scripting guy, mabe you should use newsgroup for .vbs scripting
    and ask there how to prepare this:
    microsoft.public.scripting.vbscript

    Best regards

    Meinolf Weber
     
    Meinolf Weber [MVP-DS], Aug 7, 2009
    #6
  7. mr555

    mr555 Guest

    Hi Meinolf

    I have come accross a defrag script works well, will share this with everyone

    thanks again for your help

    ' DefragAll.vbs
    ' Defrag All Fixed Drives

    Const LogFile = "C:\Defrag.log"

    Const DriveTypeRemovable = 1
    Const DriveTypeFixed = 2
    Const DriveTypeNetwork = 3
    Const DriveTypeCDROM = 4
    Const DriveTypeRAMDisk = 5

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Drives = FSO.Drives

    For each Drive in Drives
    if Drive.DriveType = 2 then
    RunCmd Drive
    end if
    Next

    Sub RunCmd(DriveString)
    Set WshShell = WScript.CreateObject("WScript.Shell")
    RunString = "%comspec% /c echo " & WeekDayName(WeekDay(Now), True) & " " &
    Now & " " & DriveString
    Return = WshShell.Run(RunString & " >> " & LogFile & " 2>&1", 0, TRUE)
    RunString = "%comspec% /c %WINDIR%\System32\Defrag.exe " & DriveString & " -f"
    Return = WshShell.Run(RunString & " >> " & LogFile & " 2>&1", 0, TRUE)
    Set WshShell = Nothing
    End Sub
     
    mr555, Aug 9, 2009
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.