如何在Windows中为驱动器的右键单击菜单添加碎片整理选项

dcm_top

Modern versions of Windows defragment drives during regular maintenance schedules. But if you defragment manually—maybe you keep your PC turned off when not in use—you might appreciate a faster way to access the command.

Windows碎片整理驱动器的现代版本在常规维护计划中。 但是,如果您手动进行碎片整理(也许在不使用PC时将其关闭),则可能会喜欢一种更快的访问命令的方法。

If you’re using Windows Vista up through Windows 10, you probably don’t need to manually defragment your drives anymore. This especially holds true if you’re using a solid state drive (SSD), which not only need to avoid the excessive wear and tear brought on by the process, but don’t need defragmentation anyway. Windows automatically defragments drives that need it once per week—by default at 1:00 am on Wednesdays. (And it is smart enough not to defragment SSDs at all.)

如果您要通过Windows 10来使用Windows Vista,则可能不再需要手动对驱动器进行碎片整理 。 如果您使用的是固态驱动器(SSD),则尤其如此,它不仅需要避免该过程带来的过度磨损,而且也不需要进行碎片整理。 Windows每周自动对需要的驱动器进行碎片整理-默认情况下,在星期三的凌晨1:00。 (它足够聪明,根本不会对SSD进行碎片整理。)

This automatic maintenance, however, requires that your PC be turned on at that time or at least be able to wake up from sleep for the defrag to happen. If you shut your PC down when you’re not using it, you might need to defragment drives on your own once in a while. Instead of digging through tools to do it, why not add a defragment command right to the context menu you get when you right-click a drive in File Explorer?

但是,这种自动维护要求您的PC当时处于开机状态,或者至少能够从睡眠中唤醒才能进行碎片整理。 如果在不使用PC时将其关闭,则可能需要不时对自己的驱动器进行碎片整理。 除了在工具中右键单击驱动器外,为什么不直接在您获得的上下文菜单中添加碎片整理命令,也不去挖掘工具来做呢?

通过手动编辑注册表将碎片整理添加到上下文菜单 (Add Defragment to the Context Menu by Editing the Registry Manually)

To add a defragment command to the context menu, you just need to make a couple of quick edits in the Windows Registry.

要将碎片整理命令添加到上下文菜单中,只需在Windows注册表中进行几次快速编辑。

Standard warning: Registry Editor is a powerful tool and misusing it can render your system unstable or even inoperable. This is a pretty simple hack and as long as you stick to the instructions, you shouldn’t have any problems. That said, if you’ve never worked with it before, consider reading about how to use the Registry Editor before you get started. And definitely back up the Registry (and your computer!) before making changes.

标准警告:注册表编辑器是一个功能强大的工具,滥用它会使您的系统不稳定甚至无法运行。 这是一个非常简单的技巧,只要您按照说明进行操作,就不会有任何问题。 也就是说,如果您以前从未使用过它,请在开始之前考虑阅读有关如何使用注册表编辑器的信息 。 并在进行更改之前一定要备份注册表 (和您的计算机 !)。

Open the Registry Editor by hitting Start and typing “regedit.” Press Enter to open Registry Editor and give it permission to make changes to your PC.

通过单击开始并键入“ regedit”来打开注册表编辑器。 按Enter键打开注册表编辑器,并授予其对PC进行更改的权限。

own_1

In the Registry Editor, use the left sidebar to navigate to the following key:

在注册表编辑器中,使用左侧边栏导航至以下键:

HKEY_CLASSES_ROOT\Drive\shell
dcm_2

Next, you’ll create a new key inside the shell key. Right-click the shell key and choose New > Key. Name the new key “runas.”

接下来,您将在shell键中创建一个新键。 右键单击shell密钥,然后选择“新建”>“密钥”。 将新密钥命名为“ runas”。

dcm_3

Now, you’ll change the (Default) value inside the new runas key. With the runas key selected, double-click the (Default) value to open its properties window.

现在,您将在新的runas键中更改(Default)值。 选择runas键后,双击(Default)值以打开其属性窗口。

dcm_4

In the properties window, set the value in the “Value data” box to “Defragment” and then click “OK.” This gives the command the name that will appear on the context menu.

在属性窗口中,将“值数据”框中的值设置为“碎片整理”,然后单击“确定”。 这为命令提供了将出现在上下文菜单中的名称。

dcm_5

Optionally, you can also set the command so that it only appears if you hold Shift down while right-clicking a drive—much the same way that the “Open Command Prompt” command is hidden unless you Shift+right-click a folder. To to that, right-click the runas key and choose New > String Value. Name the new value “Extended.” You don’t need to make any changes to it. Just having that string there will cause the command to be hidden behind Shift key access.

(可选)您还可以设置命令,使其仅在右键单击驱动器时按住Shift键时才显示-与隐藏“打开命令提示符”命令的方式相同,除非您按住Shift键并右键单击文件夹。 为此,右键单击runas键,然后选择“新建”>“字符串值”。 将新值命名为“扩展”。 您无需对其进行任何更改。 仅在其中具有该字符串将导致命令隐藏在Shift键访问之后。

dcm_6

Whether you took the optional step of creating the Extended value or not, the rest of the process is the same. You’ll next need to create a new key inside your runas key. Right-click the runas key and choose New > Key. Name the new key “command.”

无论您是否采取了创建扩展值的可选步骤,其余过程都是相同的。 接下来,您需要在runas键中创建一个新键。 右键单击runas键,然后选择“新建”>“键”。 将新键命名为“命令”。

dcm_7

Now, you’ll change the (Default) value inside the new command key. With the command key selected, double-click the (Default) value to open its properties window.

现在,您将在新命令键内更改(Default)值。 选择命令键后,双击(Default)值以打开其属性窗口。

dcm_8

The (Default) value specifies the actual command that will run when you select the option on the context menu. For our example, we’re going to call the command prompt defrag command and have it run with the default options, but with the verbose switch on so you can see the output of the command. To do that, type the following text into the “Value data” box and then click “OK.”.

(Default)值指定在上下文菜单中选择选项时将运行的实际命令。 对于我们的示例,我们将调用命令提示符defrag命令,并使其以默认选项运行,但要启用详细开关,以便您可以看到命令的输出。 为此,请在“数值数据”框中键入以下文本,然后单击“确定”。

defrag %1 -v
dcm_9

Since we’re calling the command prompt defrag command, you can also use any of the switches that command supports if you prefer. We’ve got a great guide that digs deeper into the defrag command and covers those additional options.

由于我们正在调用命令提示符defrag命令,因此您也可以根据需要使用该命令支持的任何开关。 我们有一个很好的指南,它对defrag命令进行了更深入的介绍,并涵盖了这些其他选项。

The changes should take place immediately, so you can exit out of Registry Editor. To test it out, just right-click (or Shift+right-click if you set up that option) any drive  and make sure the “Defragment” command is there.

更改应立即进行,因此您可以退出注册表编辑器。 要对其进行测试,只需右键单击(或在设置该选项的情况下按Shift +右键单击)任何驱动器,并确保其中有“碎片整理”命令。

dcm_10

When you run the command—which can take some time—you should see a command prompt window with the results.

运行命令(可能要花一些时间)时,应该会看到带有结果的命令提示符窗口。

dcm_11

If you want to reverse the changes at any time, just go back into the Registry and delete the runas key that you created. This will automatically delete any values and other keys you created inside the runas key and remove the command from your context menu.

如果您想随时撤消更改,只需返回注册表并删除您创建的runas项。 这将自动删除您在runas键中创建的所有值和其他键,并从上下文菜单中删除该命令。

下载我们的一键式注册表黑客 (Download Our One-Click Registry Hacks)

dcm_12

If you don’t feel like diving into the Registry yourself, we’ve created some registry hacks you can use. The “Add Defrag to Context Menu” hack adds the defragment command to the regular context menu. The “Add Defrag to Shift Context Menu” adds the defragment command to the context menu you get when you use Shift+right-click. And the “Remove Defrag from Context Menu” removes the command no matter which way you added it. All three hacks are included in the following ZIP file. Double-click the one you want to use and click through the prompts.

如果您不想自己进入注册表,我们已经创建了一些可以使用的注册表黑客。 “将碎片整理添加到上下文菜单” hack将碎片整理命令添加到常规上下文菜单中。 “将碎片整理添加到Shift上下文菜单”将使用Shift +右键单击将碎片整理命令添加到您所获得的上下文菜单中。 而且“无论从哪种方式添加”,“从上下文菜单中删除碎片整理”都将删除该命令。 以下ZIP文件中包含所有这三种黑客。 双击您要使用的一个,然后单击提示。

Defrag Context Menu Hacks

碎片整理上下文菜单黑客

These hacks are really just the runas key, stripped down to the additional keys and values we talked about in the previous section and then exported to a .REG file. Running the hacks just modifies the value. And if you enjoy fiddling with the Registry, it’s worth taking the time to learn how to make your own Registry hacks.

这些hack实际上只是runas密钥,被精简为上一节中讨论的其他密钥和值,然后导出到.REG文件。 运行hack只是修改了价值。 而且,如果您喜欢使用注册表,则值得花时间学习如何制作自己的注册表黑客

翻译自: https://www.howtogeek.com/howto/windows-vista/add-defragment-to-the-right-click-menu-for-a-drive/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值