Windows Vista Forums

Disk Defragmenter from Command Prompt

  1. #1
    <!-- google_ad_section_start -->Disk Defragmenter from Command Prompt<!-- google_ad_section_end -->

    Disk Defragmenter from Command Prompt
    How to Run Disk Defragmenter from the Command Prompt in Vista
    Published by Brink is offline
    31 Jul 2007
    Disk Defragmenter from Command Prompt

    How to Run Disk Defragmenter from the Command Prompt in Vista



    information   Information
    This will show you how to run Vista Disk Defragmenter from the command prompt instead of the program within Vista to use more options and details.





    Here's How:

    Note   Note
    Wait until your hard drive stops running before closing the command prompt to allow the defragmentation to finish. It may take a while to finish depending on how large and fragmented your hard drive is.

    1. Open a elevated command prompt.

    2. Choose the option you want to do below.

    3. For a Complete List of Commands -
    A) In the elevated command prompt, type defrag.exe -? and press Enter. (See screenshot below)
    Disk Defragmenter from Command Prompt-defrag_help.jpg
    4. To Defragment a Drive or Volume -

    A) In the elevated command prompt, type a option in bold below you want to do. (See screenshot below)
    • defrag.exe c: for the C: drive
      NOTE: You can use whatever drive letter to defrag it.
    • defrag.exe -c for all drives or volumes.
    B) Press Enter.
    Disk Defragmenter from Command Prompt-defrag_c_drive.jpg
    5. To Perform an Analysis Only and Not Defragment -
    A) In the elevated command prompt, type the option in bold below. (See screenshot below)

    • defrag.exe c: -a for an analysis on the C: drive
      NOTE: You can use whatever drive letter to defrag it.
    B) Press Enter.
    Disk Defragmenter from Command Prompt-defrag_a.jpg
    6. To Perform a Partial Defragmentation Only -
    A) In the elevated command prompt, type a option in bold below you want to do. (See screenshot below)

    • defrag.exe c: -r for the C: drive.
      NOTE: You can use whatever drive letter to defrag it.
    • defrag.exe -c -r for all drives or volumes.
    B) Press Enter.
    Disk Defragmenter from Command Prompt-defrag_c_drive_r.jpg
    7. To Perform a Full Defragmentation -
    A) In the elevated command prompt, type a option in bold below you want to do. (See screenshot below)

    • defrag.exe c: -w for the C: drive.
      NOTE: You can use whatever drive letter to defrag it.
    • defrag.exe -c -w for all drives and volumes.
    B) Press Enter.
    Disk Defragmenter from Command Prompt-defrag_c_drive_w.jpg
    8. To Force a Defragmentation on a Drive With Low Space -
    A) In the elevated command prompt, type a option in bold below you want to do. (See above sections)

    • defrag.exe c: -f for the C: drive.
    • defrag.exe c: -w -f for the C: drive with full defragmentation.
    • defrag.exe c: -r -f for the C: drive with partial defragmentation.
    • defrag.exe -c -f for all drives and volumes.
    • defrag.exe -c -w -f for all drives with full defragmentation.
    • defrag.exe -c- r -f for all drives with partial defragmentation.
    B) Press Enter.
    9. For Verbose or Detailed Mode -
    A) In the elevated command prompt, type a option in bold below you want to do. (See screenshot below)

    • defrag.exe c: -f -v for the C: drive.
    • defrag.exe c: -a -v for the C: drive with analysis.
    • defrag.exe c: -w -f -v for the C: drive with full defragmentation.
    • defrag.exe c: -r -f -v for the C: drive with partial defragmentation.
    • defrag.exe -c -f -v for all drives and volumes.
    • defrag.exe -c -w -f -v for all drives with full defragmentation.
    • defrag.exe -c- r -f -v for all drives with partial defragmentation.
    B) Press Enter.
    Disk Defragmenter from Command Prompt-defrag_a_v.jpg
    That's it,
    Shawn



    Published by


    Brink's Avatar
    Administrator

    Join Date: Apr 2007
    Location: Texas, USA
    Posts: 31,212
    Array

    Tutorial Tools


    Applies to

    All Vista Versions
    64 Bit & 32 Bit


  2.   


  3. #1
    MilesAhead's Avatar

    Eclectician



    Join Date : Jan 2008
    Posts : 2,301
    Vista Home Premium 64 bit SP1
    Local Time: 07:47 AM
    usa

    Re: How To Make Vista more responsive and faster

    Brink, just a note... it seems like the -b switch to defrag boot files still works, even though when you do "defrag /?" it doesn't show up in the param list. I just defragged with -b switch.

    Last edited by MilesAhead; 04 Feb 2009 at 01:51 PM.
      My System SpecsSystem Spec

  4.   


  5. #2
    Brink's Avatar

    Administrator


    Join Date : Apr 2007
    Texas, USA
    Posts : 31,212
    64-bit Windows 8.1 Enterprise (RTM)
    Local Time: 06:47 AM
    usa us texas

      Thread Starter

    Re: Disk Defragmenter from Command Prompt

    Strange MilesAhed, I cannot get defrag.exe -b to work in a elevated command prompt, but can with this tutorial's shortcut.

    Defragment Boot Files - Create Shortcut

      My System SpecsSystem Spec

  6. #3
    MilesAhead's Avatar

    Eclectician



    Join Date : Jan 2008
    Posts : 2,301
    Vista Home Premium 64 bit SP1
    Local Time: 07:47 AM
    usa

     

    Re: Disk Defragmenter from Command Prompt

    Quote Originally Posted by Brink View Post
    Strange MilesAhed, I cannot get defrag.exe -b to work in a elevated command prompt, but can with this tutorial's shortcut.

    Defragment Boot Files - Create Shortcut

    Hmmmm, do Path and see if C:\Windows\system32 is in your path

    I have Auslogics defrag but their command line version is cdefrag.exe. I don't see another defrag.exe on my machine. Plus doing defrag /? brings up the help info so it must be going to the windows defrag.exe

    That's weird.

      My System SpecsSystem Spec

  7. #4
    Brink's Avatar

    Administrator


    Join Date : Apr 2007
    Texas, USA
    Posts : 31,212
    64-bit Windows 8.1 Enterprise (RTM)
    Local Time: 06:47 AM
    usa us texas

      Thread Starter

    Re: Disk Defragmenter from Command Prompt

    Tru Dat.

      My System SpecsSystem Spec

  8. #5



    Member
    Join Date : Dec 2008
    TDot
    Posts : 58
    Vista Home Premium 64bit
    Local Time: 05:47 AM
    canada ca ontario

     

    Re: Disk Defragmenter from Command Prompt

    is there a command thats possbile to disable everything related to defrag so it doesnt run auto like when i turn on my computer the defragger always says "Analyzing disk" and it lags up my hole computer and i turned off te schedual thing already

      My System SpecsSystem Spec

  9. #6
    Brink's Avatar

    Administrator


    Join Date : Apr 2007
    Texas, USA
    Posts : 31,212
    64-bit Windows 8.1 Enterprise (RTM)
    Local Time: 06:47 AM
    usa us texas

      Thread Starter

    Re: Disk Defragmenter from Command Prompt

    Hi Bobo,

    Is this happening during boot, or when Vista starts up?

    Since you already turned off the Disk Defragmenter schedule, you might check to see if it is listed as a startup program.

    If this is happening during boot up, then see if letting it finish will stop it from running at the next boot up.

    Hope this helps for now,
    Shawn

      My System SpecsSystem Spec

  10. #7


    Join Date : Sep 2009
    Posts : 4
    vista home premium 32 bit
    Local Time: 06:47 AM


     

    Re: Disk Defragmenter from Command Prompt

    how would i know when its done defragmenting doing this through the comand prompt?

      My System SpecsSystem Spec

  11. #8
    Brink's Avatar

    Administrator


    Join Date : Apr 2007
    Texas, USA
    Posts : 31,212
    64-bit Windows 8.1 Enterprise (RTM)
    Local Time: 06:47 AM
    usa us texas

      Thread Starter

    Re: Disk Defragmenter from Command Prompt

    Hello David,

    When it's done, you will see the C:\Windows\System32> command prompt at the bottom. It depends on how large your hard drive is and how defragmented it is for how long it may take to run though. I would plan for it to run for around a hour to be safe though.

    Hope this helps,
    Shawn

      My System SpecsSystem Spec

  12. #9


    Join Date : Sep 2009
    Posts : 4
    vista home premium 32 bit
    Local Time: 06:47 AM


     

    Re: Disk Defragmenter from Command Prompt

    thanx brink. ive been tryin to defrag my computer through windows but it never finishes.

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast

Disk Defragmenter from Command Prompt
Similar Threads
Tutorial Category
privileges from install disk command prompt Vista installation & setup
Disk Defragmenter Command Line Switch? Vista file management
Windows Vista Check Disk & Disk Defragmenter General Discussion
Solved Make a command prompt run a command as soon as it opens? General Discussion
Rescue documents using Repair disk and command prompt Vista General