Default Browser - set url association with PowerShell
Something that is helpful to know for complicated environments.
Background:
We have a legacy software that is in the process of being rewritten as a Blazor application, as we begin integrating these things together one need is to make sure that invoked urls do not open in Internet Explorer.
Policy and OU based controls are not available within the timeline we're looking at. However we have an advantage in the fact that we're already using a .ps1 script that prepares some environment needs before the software executes.
Other alternatives:
A popular recommendation for handling this is to work within the DefaultAssociationsConfiguration structure. This is a good option, and is well covered in articles like this: set-default-browser-to-microsoft-edge-using-powershell/
Why this solution:
Components:
Registry values:
- HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
- HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice
PowerShell Registry Tools:
Get the property value of a specific item:
Set the property value of a specific item:
List of potentially useful ProgID values:
| IE.HTTP | Internet Explorer |
| ChromeHTML | Chrome |
| MSEdgeHTM | Edge |
Testing:
Testing showed this change to be effective, but it does involve a user confirmation step.
The next time the protocol was invoked the user was prompted with "How would you like to open?" which is sufficient for our environment.
For another environment it might be necessary to find the properties needed to control this without user confirmation. (If anyone does that research I'd be interested to hear about it.)
Note: by "protocol was invoked" I specifically mean execution invoked via explorer (think of using a .lnk file, or clicking a link in outlook). When you already have a browser open, and click a link inside that browser it handles it directly without asking explorer what the shell association is.
Implementation:
Here is the code we've added to an existing PowerShell script:
Comments
Post a Comment