
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進行更改的權限。
In the Registry Editor, use the left sidebar to navigate to the following key:
在系統資料庫編輯器中,使用左側邊欄導航至以下鍵:
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”。
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)
值以打開其屬性視窗。
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.
在屬性視窗中,将“值資料”框中的值設定為“碎片整理”,然後單擊“确定”。 這為指令提供了将出現在上下文菜單中的名稱。
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鍵通路之後。
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
鍵,然後選擇“建立”>“鍵”。 将新鍵命名為“指令”。
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)
值以打開其屬性視窗。
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
指令,并使其以預設選項運作,但要啟用詳細開關,以便您可以看到指令的輸出。 為此,請在“數值資料”框中鍵入以下文本,然後單擊“确定”。
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 +右鍵單擊)任何驅動器,并確定其中有“碎片整理”指令。
When you run the command—which can take some time—you should see a command prompt window with the results.
運作指令(可能要花一些時間)時,應該會看到帶有結果的指令提示符視窗。
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)
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/