1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem Scheduled Defrag on Domain

Discussion in 'Software' started by timebomb, Oct 11, 2012.

  1. timebomb

    timebomb New Member

    Hey all,

    I'm looking at implementing a scheduled defrag across a range of computers on a domain, setting up a scheduled task using defrag.exe seems to be the best way to organise this but I am having trouble making it work.

    Here is the command I've been using, I find that the task is created but when I go to run it it does not actually take place. I'm sure I had it working before so there is probably some niggling error somewhere.

    schtasks /create /tn "Defrag000" /sc monthly /mo 1 /d 1 /st 21:30:00 /s \\%computername% /u administrator /p SecurePW /ru system /tr "c:\windows\system32\defrag.exe c:\ -v >> c:\defrag\r_%computername%.log"

    Does anyone have any ideas as to why this isn't working or can they suggest another option perhaps?


  2. dales

    dales Terabyte Poster

    What is the error code that the scheduled task is generating, if its not added to the scheduled tasks list you might get something if you pipe the command through to a text file so something like "full command >> c:\output.txt"
    Certifications: vExpert 2014+2015+2016,VCP-DT,CCE-V, CCE-AD, CCP-AD, CCEE, CCAA XenApp, CCA Netscaler, XenApp 6.5, XenDesktop 5 & Xenserver 6,VCP3+5,VTSP,MCSA MCDST MCP A+ ITIL F
    WIP: Nothing
  3. timebomb

    timebomb New Member

    After deconstructing it somewhat the scheduled task runs successfully if I remove the command to output to the log file. While its not essential it would be nice to have a log file available on the computer itself.

    schtasks /create /tn "Defrag100" /sc monthly /mo 1 /d 1 /st 21:30:00 /ru system /tr "defrag.exe c:\"
  4. SimonD
    Honorary Member

    SimonD Terabyte Poster

    Silly question but have you looked at Raxco for defrag software? it's not too expensive and has all the reporting and management you would want.
    Certifications: CNA | CNE | CCNA | MCP | MCP+I | MCSE NT4 | MCSA 2003 | Security+ | MCSA:S 2003 | MCSE:S 2003 | MCTS:SCCM 2007 | MCTS:Win 7 | MCITP:EDA7 | MCITP:SA | MCITP:EA | MCTS:Hyper-V | VCP 4 | ITIL v3 Foundation | VCP 5 DCV | VCP 5 Cloud | VCP6 NV | VCP6 DCV | VCAP 5.5 DCA
    WIP: VCP6-CMA, VCAP-DCD and Linux + (and possibly VCIX-NV).
  5. BigG

    BigG Nibble Poster

    If the machines are windows 7 then they auto defrag at 3am (I think).
    You can probably change this with group policy if required

    Certifications: BSc, Prince2 Practitioner, MCSA Win7, MCSA 2008
    WIP: Vmware, ITILv3 on the back burner
  6. timebomb

    timebomb New Member

    We're looking for it to be free ideally, I'm aware Windows Server 2008 enables more around implementing defrag across the domain so a scheduled task will have to do until we move to 2008.

    All machines are XP as well so we are quite limited!

    I got it working anyway using the following command, it seems to be the outputting of the log file which was causing the problem:

    schtasks /create /tn "DefragFO" /sc monthly /mo FIRST /d SUN /st 21:30:00 /ru system /tr "defrag.exe c:\"

Share This Page