Drop down box addition?

Phoenix

Well-known member
Joined
Oct 26, 2021
Messages
115
Reaction score
8
I freqeuntly use Optimize (defragment)
but do not like leaving the process
for Windows to decide when to do it.
What I would like to do is plce the option
to run the utility from the helpful
right-click drop-down box that pops up in
explorer and other places.
Is this possible?
If so, how?
Any assistance apprecited.
 

ToolGuy

Member
Joined
Feb 13, 2023
Messages
6
Reaction score
3
Yes, it is possible to add the Optimize (defragment) option to the right-click context menu in Windows. Here's how:

  1. Open File Explorer and navigate to the C:\Windows\System32 folder.
  2. Scroll down and locate the "defrag.exe" file.
  3. Right-click on "defrag.exe" and select "Create shortcut".
  4. A prompt will appear asking if you want to place the shortcut on the desktop. Click "Yes" to create the shortcut.
  5. Move the shortcut to a location of your choice, such as the desktop or a folder.
  6. Right-click on the shortcut and select "Properties".
  7. In the "Target" field, add the following command line option at the end of the path: " /c /h".
  8. Click "Apply" and then "OK" to save the changes.
The shortcut is now configured to run the Optimize (defragment) utility. To add the shortcut to the right-click context menu, follow these steps:

  1. Open the Registry Editor by pressing the Windows key + R, typing "regedit" and pressing Enter.
  2. Navigate to the following registry key: HKEY_CLASSES_ROOT\Drive\shell
  3. Right-click on the "shell" key and select "New" -> "Key".
  4. Name the new key "Defrag".
  5. Right-click on the "Defrag" key and select "New" -> "Key".
  6. Name the new key "command".
  7. Double-click on the "(Default)" value in the right pane.
  8. In the "Value data" field, enter the path to the defrag.exe shortcut, including the "/c /h" command line option.
  9. Click "OK" to save the changes.
The Optimize (defragment) option should now appear in the right-click context menu when you right-click on a drive in File Explorer. Note that making changes to the registry can be risky, so it's a good idea to back up the registry before making any changes.
 

Vote:

Phoenix

Well-known member
Joined
Oct 26, 2021
Messages
115
Reaction score
8
Thanks.
Will try it.

Tried.
Got to the point of naming new key Defrag.
Next step, when naming the command, I double-clicked on the "(Default)" value in the right pane.
In the "Value data" field, entered the path to the defrag.exe shortcut,
which was ddfgui.exe
as
%windir%\system32\dfrgui.exe /c /h
Clicked "OK" to save the changes

The option of Defrag does indeed show up in the context menu, yet
a window pops up on activation stating there is no application associated.

I am sure this is operator error....
Guidance?
 
Last edited:

Vote:

Phoenix

Well-known member
Joined
Oct 26, 2021
Messages
115
Reaction score
8
In the "Value data" field, I entered the path to the defrag.exe shortcut, including the "/c /h" command line option
by typing
%windir%\system32\defrag.exe /c /h

Should I have instead just used
defrag /c /h ?


Hmph. That did not work either.
Same error message popped up.
 
Last edited:

Vote:

ToolGuy

Member
Joined
Feb 13, 2023
Messages
6
Reaction score
3
In the "Value data" field, I entered the path to the defrag.exe shortcut, including the "/c /h" command line option
by typing
%windir%\system32\defrag.exe /c /h

Should I have instead just used
defrag /c /h ?


Hmph. That did not work either.
Same error message popped up.
If you prefer to use the command "defrag /c /h" instead of the path to the defrag.exe shortcut, you can certainly do so. However, make sure that you enclose the command in quotes and add a space before the "/c /h" option, like this:

"defrag" /c /h

If you tried this and it didn't work, it's possible that there may be an issue with your registry settings or the permissions for the current user.
 

Vote:

Phoenix

Well-known member
Joined
Oct 26, 2021
Messages
115
Reaction score
8
If you prefer to use the command "defrag /c /h" instead of the path to the defrag.exe shortcut, you can certainly do so. However, make sure that you enclose the command in quotes and add a space before the "/c /h" option, like this:

"defrag" /c /h

If you tried this and it didn't work, it's possible that there may be an issue with your registry settings or the permissions for the current user.
Simple question from a simple mind...
Changes to registry require restart of pc before taking effect, yes?

Rebooted pc.
In the command key I have "defrag" /c /h
Not working
Did this while in administrator account.
Wondering if I must specify in there the complete path to defrag, as in
"C:\Windows\System32\defrag" /c /h

That did not work either
 
Last edited:

Vote:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top