Disk check, cleanup, and defrag script with results to output file

Posted on 2008-11-11
Last Modified: 2012-05-05
I would like to write a simple batch file that does a disk check, defrag, and cleanup and write the results to an outupt file on the local computer it is running the maintenance on. I have done some research and found snippets of code (attached) but need it customized so that it will execute and spit the results to an ouput file. Right now, the batch file doesn't run and I don't believe there is any code to write the results to a file. If anybody could help me with this, I would appreciate it.
Question by:ITRSupport
    LVL 67

    Accepted Solution

    Not sure about disk check, since normally the system needs to be rebooted because the volume is mounted - unless you're just wanting to view the results...

    And cleanup manager is prompted - you'd have to select what you want to clean.
    If just temp files, then try this:
    chkdsk c: > c:\results.txt
    defrag c: -f >> c:\results.txt
    echo y|del %temp% >> c:\results.txt
    del "%userprofile%\local settings\temp\*.* /q" >> c:\results.txt

    Open in new window


    Author Closing Comment

    That worked...thank you very much!
    LVL 67

    Expert Comment

    Glad I could help - thanx for the grade! :^)

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    This article was inspired by a question here at Experts Exchange ( The requirements stated in that question are (1) reduce the file size of a large number of…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now