Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 右鍵選單出現兩個「記事本」?批次檔修復檔案關聯移除重複項

編輯:Windows 7 系統介紹

問題成因

系統在 C:\Windows 與 C:\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. 另存新檔,檔名 修復記事本.bat,儲存類型選「所有檔案」。
  2. 雙擊執行該批次檔,完成後右鍵選單將只剩一個「記事本」。
右鍵選單雙重記事本 notepad.exe 兩個位置

原理說明

批次檔透過判斷 %systemroot%\notepad.exe 是否存在,決定使用哪個路徑,並統一寫入三個關鍵的檔案關聯登錄鍵值,強制移除重複項。此法不需刪除實體檔案,安全且有效。

Copyright © Windows教程網 All Rights Reserved