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

Performance & Maintenance Disk Defragmenter from Command Prompt

Brink

Staff member
mvp
Disk Defragmenter from Command Prompt How to Run Disk Defragmenter from the Command Prompt in Vista
This will show you how to run Vista's Disk Defragmenter from the command prompt instead of the program to use more options.
Published by Brink Category: Performance & Maintenance 
#1
ByLine
How to Run Disk Defragmenter from the Command Prompt in Vista
Synopsis
This will show you how to run Vista's Disk Defragmenter from the command prompt instead of the program to use more options.
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.

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



 
Last edited by a moderator:

MilesAhead

Eclectician
Vista Guru
Gold Member
#2
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:

MilesAhead

Eclectician
Vista Guru
Gold Member
#4
Strange MilesAhed, I cannot get defrag.exe -b to work in a elevated command prompt, but can with this tutorial's shortcut.

http://www.vistax64.com/tutorials/157357-defragment-boot-files-create-shortcut.html

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. :)
 
#6
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
 

Brink

Staff member
mvp
#7
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
 

Brink

Staff member
mvp
#9
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
 
#12
I am having issues involving trying to defrag.My hard drive is 297 G. Each time I defrag my C drive properties says I have less and less free space and then reccommends to defrag.I have defraged both through normal methods and command prompt using advice from this forum. I've scanned my systems and it reports no file errors or bad clusters. I use this computer daily and don't have a back up laptop to use while trying to send this one to be looked at by someone more knowledgeable. I have already done a full backup of all files and programs, and am thinking to reset computer to factory specs. I don't understand.Please advise.Thank You
 
#14
I have tried your methods of system defragmentation but what happens is that a command box flashes up for second then disappears. I've tried various commands suggested in the tutorial but none of them work. Please help :(
 
#16
Brilliant! I never knew about this before. Just done it on my laptop which has never been done before. Took ages, but, I had 51.2GB free space before, now I have 83.3GB free! Thanks :)
 
#17
Brink, you are amazing. I was getting nowhere at all with the GUI, but this got right to work. This machine is going out the door so I didn't want to install Defraggler.

Be well,
p.
 
#19
Hiyya Shawn I am running this one too as the Auslogics came up with me having to buy a fix it program and I was under the impression that it was a freebie.

Trouble is there are so many defrag apps now it makes your head spin:confused:

Anyway it seems logical to me to run the Windows one anyway.

John