Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Forums > Tutorials

Vista - Disk Defragmenter from Command Prompt

Comment
 

Disk Defragmenter from Command Prompt

How to Run Disk Defragmenter from the Command Prompt in Vista
Published by Brink
08-01-2007

How to Run Disk Defragmenter from the Command Prompt in Vista


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.
RELATED LINKS:


Here's How:

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)
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.
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.
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.
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.
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.
defrag_a_v.jpg
That's it,
Shawn

Published by
Brink's Avatar
Administrator

Join Date: Apr 2007
Location: Texas, USA
Posts: 26,110
Rep Power: 150
Brink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond reputeBrink has a reputation beyond repute

Tutorial Tools

Applies to
All Vista Versions
64 Bit & 32 Bit

Old 02-04-2009  
MilesAhead


Vista Home Premium 64 bit SP1
 
 

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; 02-04-2009 at 01:51 PM..
My System SpecsSystem Spec
Old 02-04-2009  
Brink


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

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
Old 02-04-2009  
MilesAhead


Vista Home Premium 64 bit SP1
 
 

Re: Disk Defragmenter from Command Prompt

Quote  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
Old 02-04-2009  
Brink


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

Re: Disk Defragmenter from Command Prompt

Tru Dat.
My System SpecsSystem Spec
Old 07-04-2009  
soldier000


Vista Home Premium 64bit
 
 

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
Old 07-04-2009  
Brink


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

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
Old 09-27-2009  
davidjames29365


vista home premium 32 bit
 
 

Re: Disk Defragmenter from Command Prompt

how would i know when its done defragmenting doing this through the comand prompt?
My System SpecsSystem Spec
Old 09-27-2009  
Brink


Vista x64 Ultimate SP2, Windows 7 Ultimate x64
 
 

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
Old 09-28-2009  
davidjames29365


vista home premium 32 bit
 
 

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
Comment

Tutorial Tools


Similar Threads
Tutorial Category
Disk Defragmenter Command Line Switch? Vista file management
Windows Vista Check Disk & Disk Defragmenter General Discussion
Windows Vista Check Disk & Disk Defragmenter Vista performance & maintenance
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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
Tutorial powered by GARS 2.1.8m ©2005-2006

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46