Making a Custom Protocol Handler and URI Scheme! - Part 3
Tags: python, web, url, uri
Published: 2021-05-23 10:56:45

# Well, well, back again!
I am bored of saying what are we going to do today!! So, here it is, you don't need to ask! BTW - Sorry, if you find me rude. I don't want to be rude. And, if you are coming here the first time, then check these out first - [Part 1](https://dev.to/pybash/making-a-custom-protocol-handler-and-uri-scheme-part-1-37mh), [Part 2](https://dev.to/pybash/making-a-custom-protocol-handler-and-uri-scheme-part-2-4b51)!

# Today's Plan
Today is no code. We are going to working with Windows and some other non-code things! So, get ready.

# Prerequisites
Python Libraries:
- [`auto-py-to-exe`](https://github.com/brentvollebregt/auto-py-to-exe)

Be familiar with:
- The Windows Registry

# Installation
We need to install `auto-py-to-exe` to convert our application to an executable.

Install using - `$ pip install auto-py-to-exe`

Done! Everything installed!

# Let's Start
Open a new Command Prompt Window and type - `auto-py-to-exe`

A window similar to this should open - 
![autopytoexe](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi3dkrt7rnqkr1ybo6wu.png)

Now, click browse and locate your python file containing the handler. Then select **One File** in the next section and **Console Based** in the Console Window Section. Then, expand the Settings section and Put a path you can remember under Output Directory. and finally, click "CONVERT .PY TO .EXE". After it is **complete**, close the window and go back to the Command Prompt and type `regedit` and select `yes` if a [UAC](https://google.com/search?q=User Account Control) window pops up. 

## Registry Editor
**It is recommended you make a restore point before following the next steps. Changing anything other than what is mentioned here could even break your whole computer. The author is not liable for any changes you do further. Follow the next steps at your own risk.**

After you have read the above, follow these steps - 
- Inside Registry Editor right-click **HKEY_CLASSES_ROOT** and create a new key
- Name the key whatever you want your protocol to be called! `python` for my case.
- Inside the `python` key create a new String Value and name it "URL Protocol"
- Under `python` create a new key and name it `shell`. Under `shell` create new key and name it `open`.
- And finally, under `shell` create a key named `command`.
- Now inside `command` change the value of `(Default)` to this `"D:/path/to/your/exe/file/within/quotes" "%1"`
- And Done! Now close registry editor and open up a browser.
- Type - `python://D:/path/to/any/python/file.py` in the address bar and press enter.
- Enjoy!

# I am Super Sorry
I did not post for the past month or so... Don't be mad. I was working on the Documentation for py-everything. And that took all of my time... I had this post written before hand just a tiny part was left and I couldn't complete it. But now I am super happy to publish this post and also announce that py-everything 2.0.0 just got released with tons of new features, CLIs, modules, etc. So go check that out as well. :cry:

py-everything:
{% github pybash1/py_everything %}

# Goodbye! And see you soon!
Hope you are enjoying this series so far. And stay tuned for Part 4. You are gonna love it. I am going to keep Part 4 a surprise and not spoil it. And as always, byeeeeeee!