前往
大廳
主題

用.reg編輯註冊表,建立副檔名的程式關聯的手搓記錄(緩慢更新中)

持久信念 | 2022-02-24 23:56:17 | 巴幣 0 | 人氣 979

以obb為例子 以下為.obb文件建立winrar和7z的兩種程式關聯
第一個是附檔名在註冊表裡關聯的名稱(可以自己寫,但通常都是程式名稱+文件類型,盡可能模仿原程式的填入的名稱,方便排序)
第二個是文件類型的名稱定義,我尋思去折騰搞註冊表不就是為了這個帥氣的名稱嗎
第三個是開啟程式的路徑,第四個是顯示文件類型的ico圖標
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.obb\OpenWithProgids]
"WinRAR.OBB"=""
[HKEY_CLASSES_ROOT\WinRAR.OBB]
@="WinRAR OBB 書庫"
[HKEY_CLASSES_ROOT\WinRAR.OBB\Shell\Open\Command]
@="C:\\Program Files\\WinRAR\\WinRAR.exe \"%1\""
[HKEY_CLASSES_ROOT\WinRAR.OBB\DefaultIcon]
@="%SystemRoot%\\system32\\zipfldr.dll"

[HKEY_CLASSES_ROOT\.obb\OpenWithProgids]
"7-Zip.OBB"=""
[HKEY_CLASSES_ROOT\7-Zip.OBB]
@="obb Archive"
[HKEY_CLASSES_ROOT\7-Zip.OBB\Shell\Open\Command]
@="\"C:\\Program Files\\7-Zip\\7zFM.exe\" \"%1\""
[HKEY_CLASSES_ROOT\7-Zip.OBB\DefaultIcon]
@="C:\\Program Files\\7-Zip\\7z.dll,1"

如果只是想要顯示文件圖標和自定義檔案類型名稱,不考慮直接點擊文件開啟程式的話是這樣
以GTA5的rpf為例子
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.rpf]
@="icoRAGErpf"
[HKEY_CLASSES_ROOT\icoRAGErpf]
@="Rage Package File"
[HKEY_CLASSES_ROOT\icoRAGErpf\DefaultIcon]
@="C:\\Users\user\\AppData\\Local\\New Technology Studio\\Apps\\OpenIV\\Resources\\icons\rpf.ico,0"

以上關聯的都是安裝的程式,通常這些程式本身安裝後就有動過註冊表,問題不大
如果選擇關聯非安裝的程式,可能會出現右鍵選單不出現程式的問題
以網路字體文件的woff2關聯到FontForge為例子
Windows Registry Editor Version 5.00
;woff
[HKEY_CLASSES_ROOT\.woff\OpenWithProgids]
"FontForge.woff"=""
[HKEY_CLASSES_ROOT\FontForge.woff]
@="Web OpenFont file"
[HKEY_CLASSES_ROOT\FontForge.woff\Shell\Open\Command]
@="C:\\Program Files (x86)\\FontForgeBuilds\run_fontforge.exe \"%1\""
[HKEY_CLASSES_ROOT\FontForge.woff\DefaultIcon]
@="%SystemRoot%\\System32\\fontext.dll,-419"

;woff2
[HKEY_CLASSES_ROOT\.woff2\OpenWithProgids]
"FontForge.woff2"=""
[HKEY_CLASSES_ROOT\FontForge.woff2]
@="Web OpenFont file 2"
[HKEY_CLASSES_ROOT\FontForge.woff2\Shell\Open\Command]
@="C:\\Program Files (x86)\\FontForgeBuilds\run_fontforge.exe \"%1\""
[HKEY_CLASSES_ROOT\FontForge.woff2\DefaultIcon]
@="%SystemRoot%\\System32\\fontext.dll,-419"


;default
[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
"C:\\Program Files (x86)\\FontForgeBuilds\run_fontforge.exe.ApplicationCompany"="ApplicationCompany"
[HKEY_CLASSES_ROOT\Applications\run_fontforge.exe]
"FriendlyAppName"="FontForge Editor"
[HKEY_CLASSES_ROOT\Applications\run_fontforge.exe\shell\open\command]
@="\"C:\\Program Files (x86)\\FontForgeBuilds\run_fontforge.exe\""
測試結果是缺少ApplicationCompany,會出現空白選單

然後進階操作是在右鍵選單上添加其他開啟按鈕
以html文件添加用瀏覽器無痕模式開啟為例(因為不可能設置兩個重複的相同開啟程式,所以改選單)
以下範例是html附檔名的全域設置(舊版edge命令好像在1809以上失效,不過沒差,1803才是正道)
Windows Registry Editor Version 5.00

;html
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\0_chrome]
@="Chrome Incognito"
"icon"="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe,7"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\0_chrome\command]
@="\"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\" --single-argument -incognito \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\1_edge]
@="Edge InPrivate mode"
"icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,10"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\1_edge\command]
@="\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --single-argument -inprivate \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\2_brave]
@="Brave Incognito"
"icon"="C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe,7"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\2_brave\command]
@="\"C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe\" --single-argument -incognito \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\3_firefox]
@="Firefox Private Browsing"
"icon"="C:\\Program Files\\Mozilla Firefox\\firefox.exe,4"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\3_firefox\command]
@="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -osint -private-window \"%1\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\9_Legacy]
"MUIVerb"="Legacy Browsers -private"
"subcommands"=""
"icon"="%ProgramFiles%\\Internet Explorer\\iexplore.exe,-32529"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\9_Legacy\shell\0_iexplore]
@="Internet Explorer"
"icon"="%ProgramFiles%\\Internet Explorer\\iexplore.exe,-32528"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\9_Legacy\shell\0_iexplore\command]
@="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" -private \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\9_Legacy\shell\1_edge_legacy]
@="Edge Legacy"
"icon"="%SystemRoot%\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\MicrosoftEdge.exe,0"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.html\shell\9_Legacy\shell\1_edge_legacy\command]
@="\"cmd.exe\" /c start shell:AppsFolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge -private %1"

;htm
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\0_chrome]
@="Chrome Incognito"
"icon"="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe,7"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\0_chrome\command]
@="\"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\" --single-argument -incognito \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\1_edge]
@="Edge InPrivate mode"
"icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,10"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\1_edge\command]
@="\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --single-argument -inprivate \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\2_brave]
@="Brave Incognito"
"icon"="C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe,7"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\2_brave\command]
@="\"C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe\" --single-argument -incognito \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\3_firefox]
@="Firefox Private Browsing"
"icon"="C:\\Program Files\\Mozilla Firefox\\firefox.exe,4"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\3_firefox\command]
@="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -osint -private-window \"%1\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\9_Legacy]
"MUIVerb"="Legacy Browsers -private"
"subcommands"=""
"icon"="%ProgramFiles%\\Internet Explorer\\iexplore.exe,-32529"

[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\9_Legacy\shell\0_iexplore]
@="Internet Explorer"
"icon"="%ProgramFiles%\\Internet Explorer\\iexplore.exe,-32528"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\9_Legacy\shell\0_iexplore\command]
@="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" -private \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\9_Legacy\shell\1_edge_legacy]
@="Edge Legacy"
"icon"="%SystemRoot%\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\MicrosoftEdge.exe,0"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.htm\shell\9_Legacy\shell\1_edge_legacy\command]
@="\"cmd.exe\" /c start shell:AppsFolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge -private %1"

以下是MKV的區域設置,只有在預設VLC開啟,右鍵才看得到用MPC-HC播放選單
事實上這個也可以用來添加各種選單來用舊版程式開啟文件,只要確保一個版本自己綁定註冊表就行
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VLC.mkv\shell\0_PlayWithMPCHC]
@="Play With MPC-HC"
"icon"="C:\\Program Files\\MPC-HC\\mpciconlib.dll,20"
[HKEY_CLASSES_ROOT\VLC.mkv\shell\0_PlayWithMPCHC\command]
@="\"C:\\Program Files\\MPC-HC\\mpc-hc64.exe\" \"%1\""

最後來到複雜的,直接在右鍵添加開啟程式按鈕
Windows Registry Editor Version 5.00
;
[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu]
"MUIVerb"="Apps"
"Position"="Middle"
"icon"="shell32.dll,-271"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\01]
"MUIVerb"="Calculator"
"icon"="calc.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\01\command]
@="calc.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\02]
"MUIVerb"="Notepad"
"icon"="%SystemRoot%\\System32\notepad.exe,0"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\02\command]
@="notepad.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\10]
"MUIVerb"="VMware Workstation"
"icon"="C:\\Program Files (x86)\\VMware\\VMware Workstation\\vmware.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\0_Menu\shell\10\command]
@="\"C:\\Program Files (x86)\\VMware\\VMware Workstation\\vmware.exe\" --locale zh_CN"

;
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu]
"MUIVerb"="System Tools"
"Position"="Middle"
"icon"="shell32.dll,-22"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\01]
"MUIVerb"="Control Panel"
"icon"="control.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\01\command]
@="control.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\02]
"MUIVerb"="Registry Editor"
"icon"="regedit.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\02\command]
@="regedit.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\03]
"MUIVerb"="Run"
"icon"="shell32.dll,-25"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\03\command]
@="explorer shell:::{2559A1F3-21D7-11D4-BDAF-00C04F60B9F0}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\04]
"MUIVerb"="Task Manager"
"icon"="taskmgr.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\04\command]
@="taskmgr.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\10]
"MUIVerb"="Fonts"
"icon"="%SystemRoot%\\System32\\fontext.dll,0"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\10\command]
@="control fonts"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\11]
"MUIVerb"="Programs and Features"
"icon"="shell32.dll,-271"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\11\command]
@="control /name Microsoft.ProgramsAndFeatures"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\12]
"MUIVerb"="Region and Language"
"icon"="%SystemRoot%\\System32\\intl.cpl,-200"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\12\command]
@="explorer shell:::{62D8ED13-C9D0-4CE8-A914-47DD628FB1B0}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\13]
"MUIVerb"="System"
"icon"="imageres.dll,-149"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\13\command]
@="explorer shell:::{BB06C0E4-D293-4f75-8A90-CB05B6477EEE}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\14]
"MUIVerb"="Applications"
"icon"="explorer.exe"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\14\command]
@="explorer shell:::{4234d49b-0245-4df3-b780-3893943456e1}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\15]
"MUIVerb"="Language Settings 1803"
"icon"="%SystemRoot%\\System32\\UserLanguagesCpl.dll"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\1_Menu\shell\15\command]
@="explorer shell:::{BF782CC9-5A52-4A17-806C-2A894FFEEAC5}"

;
[HKEY_CLASSES_ROOT\Directory\Background\Shell\2_Menu]
"MUIVerb"="Settings"
"Position"="Middle"
"icon"="SystemSettingsBroker.exe"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\2_Menu\shell\07]
"MUIVerb"="Time && language"
"icon"="%SystemRoot%\\System32\\ieframe.dll,-31061"
[HKEY_CLASSES_ROOT\Directory\Background\Shell\2_Menu\shell\07\command]
@="explorer ms-settings:dateandtime"

然後說一下ico後面的數字意義
文件後面的數字有兩種寫法,一個就是notepad.exe,0,純數字,代表裡面的第幾個ico位置。使用者手動選ico都會套用這個寫法。
另一種是fontext.dll,-419這種,這個是指裡面ico用的編號,基本註冊表裡面預設的都是這樣寫。
這種ico編號只能用IconsExtract這種工具查看,而且不同的作業系統會出現舊版dll有這個ico然後新版刪掉這個ico,或是新版的ico不存在在舊版dll裡面
總結就是一般的安裝的exe用純數字選ico,系統文件的ico用編號,確保不同的window的兼容性

至於有一種顯示ico的方式是顯示一張白紙,白紙裡面有exe的圖標
要使用這種現實方式有三個條件,第一個是不能有DefaultIcon,第二個是開啟指令不能用shell\open\command,要用其他指令比如shell\0_PlayWithMPCHC\command,總之就是不能用open
第三個就是不能有PerceivedType,一般來說很少會遇到這個,但如果你有安裝過其他程式的話可能會被寫入,比如值是image的話,最後你看到的是白紙裡面有jpg的圖標,而不是你想要的exe的圖標
以下是將一個遊戲文件添加白紙裡面有exe的圖標的範例,順便移除掉PerceivedType
[HKEY_CLASSES_ROOT\.txd\OpenWithProgids]
"txdworkshop4"=""
[HKEY_CLASSES_ROOT\txdworkshop4]
@="RenderWare txd File"
[HKEY_CLASSES_ROOT\txdworkshop4\shell\edit]
@="Edit with txd workshop 4.0"
[HKEY_CLASSES_ROOT\txdworkshop4\shell\edit\command]
@="C:\\Program Files\\exe\\txd workshop 4.0\\txdworkshop.exe \"%1\""
[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
"C:\\Program Files\\exe\\txd workshop 4.0\\txdworkshop.exe.ApplicationCompany"="ApplicationCompany"
[HKEY_CLASSES_ROOT\Applications\txdworkshop.exe]
"FriendlyAppName"="txd workshop 4.0"
[HKEY_CLASSES_ROOT\.txd]
"PerceivedType"=-

另外如果要在文件類型名稱使用非英文文字,需要用notepad++轉成ucs-2 little endian的格式(LE絕對是邪教編碼)
還有UWP沒有ico,只有png圖片,但如果直接模仿註冊表裡寫的ico路徑會有版本問題
UWP一更新你設置的圖標路徑就沒用了
實測後發現png圖檔在win10也可以當ico用(在右鍵選單無效),但舊的系統能不能這樣玩我就不清楚了。而且UWP更新後的路徑都會改變,除非你是要用特定版本的UWP的edge這種已經停止更新的程式,不然用UWP的png圖標基本就是給自己找麻煩
@="%SystemRoot%\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\Assets\\MicrosoftEdgeEPUB.targetsize-336.png"

最後提一個罕見的圖標設置,當你把IE設為開啟html的文件的預設(必須是.htm的附檔名),然後在.htm文件裡的html裡添加以下這一行
<META NAME="Generator" CONTENT="Microsoft Word 97">
你的該文件.htm圖標會變成word+xml的圖標,但前提是你有安裝office 2007,新的office版本不會有這個效果

//相關輔助工具
--File Types Manager
--MUICacheView
--RegFromApp
--RegistryChangesView
--IconsExtract
--Iconfinder
//附檔名註冊表相關資訊參考
//
//文件圖標顯示規則參考
//Verbs and File Associations
//CLSID相關資訊參考
//Windows 的額外檔案狀態:Shell Icon Overlay

以下是其他註冊表的記錄
--在組裝機上填上OEM的自定義文字,注意圖片格式必須為bmp格式的正方形圖片。另外新版win10和win11已經無法在控制台頁面看見OEM圖片
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation]
"Logo"="C:\\windows\\oem\\oemlogo.bmp"
"Manufacturer"="Gawr Gura"
"HelpCustomized"=dword:00000000
"Model"="PC"
"SupportPhone"="10032"


--win10右下角時鐘顯示秒數(其他平台似乎沒用)
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"ShowSecondsInSystemClock"=dword:00000001

--解决chrome下載twitter和巴哈圖片變成jfif的問題
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/jpeg]
"Extension"=".jpg"

--讓新舊edge共存,因為win更新會徹底拔掉舊版edge,這個基本沒用了,除非你要測1803在虛擬機裡
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\EdgeUpdate]
"Allowsxs"=dword:00000001

--chrome系瀏覽器STATUS_INVALID_IMAGE_HASH崩潰的解決方案,很久以前的偶發案例
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"RendererCodeIntegrityEnabled"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge]
"RendererCodeIntegrityEnabled"=dword:00000000
--

創作回應

更多創作