Last active
July 14, 2020 09:47
-
-
Save cvzi/9605658142ac9feef0f23aa762852b3c to your computer and use it in GitHub Desktop.
Open Microsoft edge links with your default browser, prevent "get help with file explorer in windows 10" links from opening.
This file contains 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
#!python3 | |
r""" | |
Open Microsoft edge links with your default browser | |
Prevent "get help with file explorer in windows 10" links from opening. | |
Instructions: | |
1. | |
Download SetUserFTA.exe from https://docs.microsoft.com/en-us/archive/blogs/windowsinternals/windows-10-how-to-configure-file-associations-for-it-pros | |
2. | |
Create a new file, name it "test.microsoftedge-file" | |
Double click the file, choose "Look for another app on this PC", select this file "edge2browser.py" as the app | |
Right click on the file, choose "Open with..." and make sure that the check is set at "Always use this app to open..." | |
3. | |
Open regedit.exe and go to "Computer\HKEY_CLASSES_ROOT\Applications\edge2browser.py\shell\open\command" and set the (Default) to: | |
C:\Windows\pyw.exe "C:\YOUR_PATH_TO_FILE\edge2browser.py" "%1" | |
4. | |
To find the ProgId (should be "Applications\edge2browser.py") use this command in the console: | |
>> reg.exe query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.microsoftedge-file\UserChoice /v ProgId | |
5. | |
To set the new file handler for the microsoft edge protocols, use these commands int he console: | |
>> SetUserFTA.exe microsoft-edge Applications\edge2browser.py | |
>> SetUserFTA.exe microsoft-edge-holographic Applications\edge2browser.py | |
>> SetUserFTA.exe read Applications\edge2browser.py | |
""" | |
import sys | |
import os | |
import webbrowser | |
import urllib.parse | |
if os.path.isfile(sys.argv[1]): | |
exit(0) | |
url = sys.argv[1].split(':', 1)[1] | |
if url.startswith('?launchContext'): | |
url = urllib.parse.unquote_plus(url.split('&url=', 1)[1]) | |
if url.startswith('https://go.microsoft.com/fwlink/?LinkId=528884'): | |
# Do not open "get help with file explorer in windows 10" | |
exit(0) | |
if not url.startswith('http'): | |
import tkinter | |
import tkinter.messagebox | |
root = tkinter.Tk() | |
root.withdraw() | |
tkinter.messagebox.showerror( | |
"edge2browser.py: Unkown url", | |
f"""edge2browser.py encountered an unkown URI: | |
{url} | |
Original argument: | |
{sys.argv[1]}""") | |
else: | |
webbrowser.open(url, new=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment