Created
April 4, 2026 10:17
-
-
Save Flameeyes/822d6a8d1db3ac1552aa3898cc808f85 to your computer and use it in GitHub Desktop.
[Claude] Use Edge's PDF icon while opening PDFs in Chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| <# | |
| .SYNOPSIS | |
| Restores PDF icon and preview pane in Explorer while keeping Chrome as the opener. | |
| .DESCRIPTION | |
| When Chrome is set as the default PDF opener, Windows resolves icons and shell | |
| extensions through the ChromePDF ProgID, which Chrome doesn't bother setting up | |
| properly. This script adds HKCU overrides on ChromePDF to: | |
| - Show Edge's PDF icon instead of Chrome's generic one | |
| - Register the Windows built-in PDF preview handler so the preview pane works | |
| The open action is untouched, so Chrome keeps opening PDF files. | |
| #> | |
| Set-StrictMode -Version Latest | |
| $ErrorActionPreference = "Stop" | |
| $PreviewHandlerGuid = "{8895b1c6-b41f-4c1c-a562-0d564250836f}" | |
| $PreviewHandlerClsid = "{3A84F9C2-6164-485C-A7D9-4B27F8AC009E}" | |
| $ChromePdfKey = "HKCU:\SOFTWARE\Classes\ChromePDF" | |
| function Set-ChromePdfIcon { | |
| $edgeIcon = Get-ItemPropertyValue "HKLM:\SOFTWARE\Classes\MSEdgePDF\DefaultIcon" -Name "(default)" -ErrorAction Stop | |
| $exePath = ($edgeIcon -split ",")[0] | |
| if (-not (Test-Path $exePath)) { | |
| throw "Edge executable not found at: $exePath — is Edge installed?" | |
| } | |
| New-Item -Path "$ChromePdfKey\DefaultIcon" -Force | Out-Null | |
| Set-ItemProperty -Path "$ChromePdfKey\DefaultIcon" -Name "(default)" -Value $edgeIcon | |
| Write-Host "Icon set to: $edgeIcon" | |
| } | |
| function Set-ChromePdfPreviewHandler { | |
| New-Item -Path "$ChromePdfKey\ShellEx\$PreviewHandlerGuid" -Force | Out-Null | |
| Set-ItemProperty -Path "$ChromePdfKey\ShellEx\$PreviewHandlerGuid" -Name "(default)" -Value $PreviewHandlerClsid | |
| Write-Host "Preview handler registered: $PreviewHandlerClsid" | |
| } | |
| function Reset-IconCache { | |
| Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue | |
| Start-Sleep -Seconds 2 | |
| Get-ChildItem "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\iconcache_*.db" -ErrorAction SilentlyContinue | | |
| Remove-Item -Force -ErrorAction SilentlyContinue | |
| Start-Process explorer.exe | |
| Write-Host "Explorer restarted and icon cache cleared." | |
| } | |
| Set-ChromePdfIcon | |
| Set-ChromePdfPreviewHandler | |
| Reset-IconCache | |
| Write-Host "Done. PDF files should now show the Edge PDF icon and preview in Explorer." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment