萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Windows 7 教學

Win7 右鍵「開啟方式」出現兩個記事本?批次檔修改登錄表關聯去重

右鍵文字檔「開啟方式」出現兩個相同的「記事本」選項,因 C:\Windows\notepad.exe 與 C:\Windows\System32\notepad.exe 兩個副本同時被註冊為開啟程式。透過批次檔修改登錄表關聯,保留單一路徑即可去重。

原因分析

Windows 目錄與 System32 目錄皆存在 notepad.exe,系統建立檔案關聯時重複註冊,導致右鍵選單重複顯示。單純刪除任一檔案會導致系統功能異常,需修正登錄表關聯指向單一路徑。

批次檔修復法

  1. 記事本貼上以下程式碼:
@echo off
if exist "%systemroot%\notepad.exe" set Npath="%systemroot%\notepad.exe %1"
if not exist "%systemroot%\notepad.exe" set Npath="%systemroot%\system32\notepad.exe %1"
reg add "HKCR\txtfile\shell\open\command" /ve /d %Npath% /t REG_SZ /f
reg add "HKCR\Applications\notepad.exe\shell\open\command" /ve /d %Npath% /t REG_SZ /f
reg add "HKCR\SystemFileAssociations\text\shell\open\command" /ve /d %Npath% /t REG_SZ /f
  1. 另存為 fix_notepad.bat(類型選「所有檔案」)。
  2. 以系統管理員身分執行該 .bat 檔案,完成後右鍵選單僅保留一個「記事本」。

原理說明

批次檔檢測 %systemroot%\notepad.exe 是否存在(優先使用),動態設定登錄表 shell\open\command 預設值,統一三個關聯機碼指向同一執行檔路徑,達到去重效果。

copyright © 萬盛學電腦網 all rights reserved