Devices Add Optimize to Context Menu of Drives in Windows 11


  • Staff
Defrag_banner.png

This tutorial will show you how to add Optimize to the context menu of drives in Windows 10 and Windows 11 to make it easier to optimize and defrag drives on demand.

Optimizing your drives can help your PC run smoother and boot up faster.

Windows 11 includes Optimize Drives that will automatically retrim a SSD or defrag a HDD as needed.
  • Retrim = Generates TRIM and Unmap hints for all currently unused sectors of the SSD or NVMe volume, notifying the underlying storage that the sectors are no longer needed and can be purged. This can recover unused capacity on thinly provisioned drives.
  • Defrag = Locates and consolidates fragmented files on local HDD volumes to improve system performance.
Optimize Drives runs automatically on a weekly schedule at the time set in automatic maintenance. You can also manually run Optimize Drives on demand as needed.


You must be signed in as an administrator to add, remove, or use the Optimize context menu.

The Optimize context menu will not work for network drives even though it is available for them.



EXAMPLE: Optimize context menu

When you right click on a drive, you will need to click/tap on Show more options first, click/tap on Optimize, and click/tap on Analyze Drive, Optimize Drive, or Optimize All Drives for what you want. A command prompt will open showing you the results.


Show_more_options.png
Optimize_drives.png



Here's How:

1 Do step 2 (add) or step 3 (remove) below for what you want.

2 Add Optimize Context Menu

A) Click/tap on the Download button below to download the file below, and go to step 4 below.​

Add_Optimize_Drives_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Drive\shell\Optimize]
"Icon"="dfrgui.exe"
"HasLUAShield"=""
"Extended"=-
"SubCommands"=""


[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\001menu]
"MUIVerb"="Analyze Drive"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\001menu\command]
@="PowerShell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, defrag %1 /A' -Verb runAs\""


[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\002menu]
"MUIVerb"="Optimize Drive"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\002menu\command]
@="PowerShell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, defrag %1 /O /H' -Verb runAs\""


[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\003menu]
"MUIVerb"="Optimize All Drives"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\Shell\Optimize\shell\003menu\command]
@="PowerShell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, defrag /C /O /H' -Verb runAs\""

3 Remove Optimize Context Menu

This is the default settings.


A) Click/tap on the Download button below to download the file below, and go to step 4 below.​

Remove_Optimize_Drives_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Drive\shell\Optimize]

4 Save the REG file to your desktop.

5 Double click/tap on the downloaded REG file to merge it.

6 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

7 You can now delete the downloaded REG file if you like.


That's it,
Shawn Brink


 

Attachments

  • Add_Optimize_Drives_context_menu.reg
    2.3 KB · Views: 319
  • Remove_Optimize_Drives_context_menu.reg
    494 bytes · Views: 267
Last edited:
Back
Top Bottom