Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Win10 使用 .reg 註冊檔來源檔案新增/修改註冊鍵值完整教學:右鍵選單加入記事本、顯示隱藏檔、移動硬碟盤符、桌面圖示修復等實用範例

編輯:關於 Windows

Windows 註冊編輯器 (regedit) 手動修改機碼值步驟繁瑣且易出錯。使用 .reg 註冊檔來源檔案 可將多項註冊變更封裝為單一檔案,雙擊即可匯入,支援新增機碼、修改值、刪除機碼,極適合系統部署、重灌後快速套用個人化設定、跨電腦同步配置。本文詳細說明 .reg 檔案語法結構、建立流程,並提供 5 個實用範例 (含完整程式碼) 可直接複製使用。

.reg 檔案基本語法結構

Windows Registry Editor Version 5.00

; 註解行以分號開頭

[HKEY_CURRENT_USER\Software\MyApp\Settings]
"ValueName"="String Data"
"DwordValue"=dword:00000001
"BinaryValue"=hex:01,02,03,04
"MultiStringValue"=hex(7):41,00,42,00,00,00,43,00,00,00

; 刪除機碼:在機碼路徑前加減號
; [-HKEY_CURRENT_USER\Software\MyApp\Settings]

; 刪除值:值名稱後加減號
; [HKEY_CURRENT_USER\Software\MyApp\Settings]
; "ValueToDelete"=-

建立 .reg 檔案標準流程

  1. 開啟記事本 (Notepad)。
  2. 複製完整程式碼 (含標頭 Windows Registry Editor Version 5.00 與空行)。
  3. 貼上至記事本。
  4. 檔案 → 另存新檔 → 儲存位置:桌面 → 檔名:MySettings.reg (副檔名 .reg) → 儲存類型:所有檔案 → 編碼:ANSI 或 UTF-16 LE (含 BOM)。
  5. 雙擊 .reg 檔案 → 使用者帳戶控制 (UAC) 提示「是」 → 確認匯入成功訊息。

五大實用範例 (可直接複製)

範例 1:資料夾/桌面右鍵選單加入「記事本」開啟

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\記事本\command]
@="notepad.exe"

記事本.reg 建立流程

另存為 .reg

桌面產生 .reg 圖示

雙擊匯入確認

匯入成功訊息

匯入完成

右鍵選單出現記事本

範例 2:所有檔案右鍵選單加入「用記事本開啟」

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\notepad]
@="用記事本開啟"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\notepad\command]
@="notepad %1"

用記事本開啟右鍵選單

範例 3:恢復資料夾選項「顯示隱藏的檔案、資料夾和磁碟機」選項 (防病毒修改)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL]
"CheckedValue"=dword:00000001
"DefaultValue"=dword:00000002
"HKeyRoot"=dword:80000001
"Id"=dword:00000002
"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"Text"="@shell32.dll,-30500"
"Type"="radio"
"ValueName"="Hidden"

範例 4:解決移動硬碟不顯示盤符 (修正 NoDriveTypeAutoRun)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000091
"NoTrayContextMenu"=dword:00000001
"NoDrives"=hex:00

範例 5:修復右鍵桌面圖示消失/重新整理失效 (重設 Explorer 路徑)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"explorer"="C:\\WINDOWS\\explorer.exe"

桌面圖示.reg 修復

進階管理建議

  • 分類歸檔: 建立資料夾 (如 D:\RegBackups\) 分類儲存:ContextMenu\、FolderOptions\、DriveLetters\、ExplorerFixes\、SystemTweaks\。
  • 版本控制: 檔名加入日期/版本:ContextMenu_Notepad_v20240115.reg。
  • 部署自動化: 批次檔無訊息匯入:regedit /s "D:\RegBackups\ContextMenu_Notepad.reg" (適用登入腳本/MDM 部署)。
  • 備份還原: 重灌前匯出關鍵機碼:regedit /e "Backup_HKCU_Software.reg" "HKEY_CURRENT_USER\Software"。

註冊檔分類歸檔範例

適用版本與注意事項

  • 本文範例針對 Windows 10 測試有效,Windows 7/8/8.1/11 大多數相容,但部分機碼路徑可能不同。
  • 修改 HKEY_LOCAL_MACHINE 需系統管理員權限 (UAC 提示)。
  • 匯入前請確認來源可信,**惡意 .reg 檔案可竄改系統關鍵設定、植入持久化後門**。
  • 建議匯入前建立系統還原點。
✅ 核心優勢: .reg 檔案 = 可版控、可部署、可審計、可分享的系統設定封裝。善用它將重複性註冊操作轉化為一次性資產。
Copyright © Windows教程網 All Rights Reserved