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.

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



 

Attachments

  • thumb_Disk_Defragmenter.png
    thumb_Disk_Defragmenter.png
    10.8 KB · Views: 453
Last edited by a moderator:
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:

My Computer

System One

  • Manufacturer/Model
    HP Pavilion m9515y
    CPU
    Phenom X4 9850
    Memory
    8 GB
    Graphics card(s)
    Some Radeon Cheapie with 512 MB Ram
    Monitor(s) Displays
    CRT
    Screen Resolution
    1280x1024
    Hard Drives
    750 GB SATA 3G 2 SIIG Superspeed docks w/WD Caviar Black Sata II or III

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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. :)
 

My Computer

System One

  • Manufacturer/Model
    HP Pavilion m9515y
    CPU
    Phenom X4 9850
    Memory
    8 GB
    Graphics card(s)
    Some Radeon Cheapie with 512 MB Ram
    Monitor(s) Displays
    CRT
    Screen Resolution
    1280x1024
    Hard Drives
    750 GB SATA 3G 2 SIIG Superspeed docks w/WD Caviar Black Sata II or III
Tru Dat. ;)
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 Computer

System One

  • Manufacturer/Model
    M8430F
    CPU
    Q6600
    Motherboard
    IPIBL-LB (Benicia)
    Memory
    4gb
    Graphics card(s)
    Evga 250 GTS
    Monitor(s) Displays
    24" Samsung T240HD
    Screen Resolution
    1680x1050
    Hard Drives
    750gb
    PSU
    OCZ GameXStream 700-Watt
    Case
    NZXT Tempest ATX Mid-Tower Case
    Cooling
    Air
    Mouse
    Logitech G500
    Keyboard
    Logitech G19
    Internet Speed
    Bell Max 10
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 Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
You're welcome David. I find that the free program Auslogics Disk Defrag is a great one to use in Vista.
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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
 

My Computer

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 :(
 

My Computer

Hello Kittsville, and welcome to Vista Forums.

See if running a sfc /scannow command may be able to fix the command prompt for you so that it will stay open afterwards.

You can also use Disk Defragmenter instead to defrag.

Hope this helps,
Shawn
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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 :)
 

My Computer

System One

  • Manufacturer/Model
    HP G60 Notebook
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.
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics card(s)
    matrox
You're most welcome. :)
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
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
 

My Computer

System One

  • Manufacturer/Model
    LEC
    CPU
    E4500 duo core
    Motherboard
    D945GN
    Memory
    2GB
    Graphics card(s)
    Inbuilt
    Sound Card
    Inbuilt
    Monitor(s) Displays
    LCD

My Computers

System One System Two

  • Operating System
    Windows 10 Pro 64-bit
    Manufacturer/Model
    Custom
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2, 4TB Samsung 990 PRO PRO M.2, 8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Mouse
    Logitech MX Master 3
    Keyboard
    Logitech wireless K800
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Other Info
    Logitech Z625 speaker system, Logitech BRIO 4K Pro webcam, HP Color LaserJet Pro MFP M477fdn, APC SMART-UPS RT 1000 XL - SURT1000XLI, Galaxy S23 Plus phone
  • Operating System
    Windows 10 Pro
    Manufacturer/Model
    HP Envy Y0F94AV
    CPU
    i7-7500U @ 2.70 GHz
    Memory
    16 GB DDR4-2133
    Sound Card
    Conexant ISST Audio
    Monitor(s) Displays
    17.3" UHD IPS touch
    Screen Resolution
    3480 x 2160
    Hard Drives
    512 GB M.2 SSD
Back
Top