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 Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Forums > Tutorials

Vista Tutorial - Disk Defragmenter from Command Prompt

Comment
 
LinkBack Tutorial Tools Display Modes
<!-- 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
07-31-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: 23,763
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
Show Printable Version Show Printable Version
Email this Page Email this Page

Applies to
All Vista Versions
64 Bit & 32 Bit

Page copy protected against web site content infringement by Copyscape

Old 02-04-2009  
MilesAhead's Avatar
MilesAhead
Aficionado


Join Date: Jan 2008
Vista Home Premium 64 bit SP1
 
Rep Power: 33
MilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to behold
  MilesAhead is offline

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 12:51 PM..
My System SpecsSystem Spec
Old 02-04-2009  
Brink's Avatar
Brink
Administrator



Join Date: Apr 2007
Vista x64 Ultimate SP2
Texas, USA
 
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
  Brink is offline

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's Avatar
MilesAhead
Aficionado


Join Date: Jan 2008
Vista Home Premium 64 bit SP1
 
Rep Power: 33
MilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to beholdMilesAhead is a splendid one to behold
  MilesAhead is offline

Re: Disk Defragmenter from Command Prompt

Quote:
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's Avatar
Brink
Administrator



Join Date: Apr 2007
Vista x64 Ultimate SP2
Texas, USA
 
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
  Brink is offline

Re: Disk Defragmenter from Command Prompt

Tru Dat.
My System SpecsSystem Spec
Comment

Tags
command, defragmenter, disk, performance & maintenance, prompt

Tutorial Tools
Display Modes


Similar Threads
Tutorial Tutorial Starter Category Comments Last Post
Rescue documents using Repair disk and command prompt magmos_019 Vista General 5 08-21-2008 08:34 AM
disk defragmenter maria23 Vista General 2 06-25-2008 08:51 AM
Command prompt "COPY" command not working in brand new Windows Vis CMD COPY command not working in Vista Vista file management 7 02-05-2008 03:20 PM
Disk Defragmenter Marjay Vista General 4 08-03-2007 09:44 AM
Disk Defragmenter IamWhoIam Vista performance & maintenance 2 07-11-2007 05:54 PM


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