Last active
May 3, 2021 08:13
-
-
Save Diagg/8e0ff26c9402a3d5e8aa5571ea41dd18 to your computer and use it in GitHub Desktop.
Various untested trick to prevent edge from hijacking the PDF viewer
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
| # Stops edge from taking over as the default .PDF viewer | |
| Write-Output "Stopping Edge from taking over as the default .PDF viewer" | |
| # Identify the edge application class | |
| $Packages = "HKCU:SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages" | |
| $edge = Get-ChildItem $Packages -Recurse -include "MicrosoftEdge" | |
| # Specify the paths to the file and URL associations | |
| $FileAssocKey = Join-Path $edge.PSPath Capabilities\FileAssociations | |
| $URLAssocKey = Join-Path $edge.PSPath Capabilities\URLAssociations | |
| # Get the software classes for the file and URL types that Edge will associate | |
| $FileTypes = Get-Item $FileAssocKey | |
| $URLTypes = Get-Item $URLAssocKey | |
| $FileAssoc = Get-ItemProperty $FileAssocKey | |
| $URLAssoc = Get-ItemProperty $URLAssocKey | |
| $Associations = @() | |
| $Filetypes.Property | foreach {$Associations += $FileAssoc.$_} | |
| $URLTypes.Property | foreach {$Associations += $URLAssoc.$_} | |
| # Add registry values in each software class to stop edge from associating as the default | |
| foreach ($Association in $Associations) { | |
| $Class = Join-Path HKCU:SOFTWARE\Classes $Association | |
| #if (Test-Path $class) | |
| # {write-host $Association} | |
| # Get-Item $Class | |
| Set-ItemProperty $Class -Name NoOpenWith -Value "" | |
| Set-ItemProperty $Class -Name NoStaticDefaultVerb -Value "" | |
| } | |
| <#eedgepdf#> | |
| Write-Output "Setting Edge back to default to takeover as default .PDF viewer..." | |
| New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | |
| $ErrorActionPreference = 'SilentlyContinue' | |
| $NoPDF = "HKCR:\.pdf" | |
| $NoProgids = "HKCR:\.pdf\OpenWithProgids" | |
| $NoWithList = "HKCR:\.pdf\OpenWithList" | |
| #Sets edge back to default | |
| If (Get-ItemProperty $NoPDF NoOpenWith) { | |
| Remove-ItemProperty $NoPDF NoOpenWith | |
| } | |
| If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) { | |
| Remove-ItemProperty $NoPDF NoStaticDefaultVerb | |
| } | |
| If (Get-ItemProperty $NoProgids NoOpenWith) { | |
| Remove-ItemProperty $NoProgids NoOpenWith | |
| } | |
| If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) { | |
| Remove-ItemProperty $NoProgids NoStaticDefaultVerb | |
| } | |
| If (Get-ItemProperty $NoWithList NoOpenWith) { | |
| Remove-ItemProperty $NoWithList NoOpenWith | |
| } | |
| If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) { | |
| Remove-ItemProperty $NoWithList NoStaticDefaultVerb | |
| } | |
| #Removes an underscore '_' from the Registry key for Edge | |
| $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_" | |
| If (Test-Path $Edge2) { | |
| Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723 | |
| } | |
| Write-Output "Operation Complete: Edge will now be able to be used for .PDF files." | |
| <#dedgepdf#> | |
| Write-Output "Stopping Edge from taking over as the default .PDF viewer..." | |
| $ErrorActionPreference = 'SilentlyContinue' | |
| $NoPDF = "HKCR:\.pdf" | |
| $NoProgids = "HKCR:\.pdf\OpenWithProgids" | |
| $NoWithList = "HKCR:\.pdf\OpenWithList" | |
| If (!(Get-ItemProperty $NoPDF NoOpenWith)) { | |
| New-ItemProperty $NoPDF NoOpenWith | |
| } | |
| If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) { | |
| New-ItemProperty $NoPDF NoStaticDefaultVerb | |
| } | |
| If (!(Get-ItemProperty $NoProgids NoOpenWith)) { | |
| New-ItemProperty $NoProgids NoOpenWith | |
| } | |
| If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) { | |
| New-ItemProperty $NoProgids NoStaticDefaultVerb | |
| } | |
| If (!(Get-ItemProperty $NoWithList NoOpenWith)) { | |
| New-ItemProperty $NoWithList NoOpenWith | |
| } | |
| If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) { | |
| New-ItemProperty $NoWithList NoStaticDefaultVerb | |
| } | |
| #Appends an underscore '_' to the Registry key for Edge | |
| $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_" | |
| If (Test-Path $Edge) { | |
| Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ | |
| } | |
| Write-Output "Operation Complete: Edge should no longer take over as the default .PDF files." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment