<p>How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it?</p>

[{'answer_id': 81954, 'author': 'MSalters', 'author_id': 15416, 'author_profile': 'https://Stackoverflow.com/users/15416', 'pm_score': 5, 'selected': False, 'text': '<p>The MSDN link is nice, but the security information there isn\'t complete. The handler registration should contain "%1", not %1. This is a security measure, because some URL sources incorrectly decode %20 before invoking your custom protocol handler.</p>\n\n<p>PS. You\'ll get the entire URL, not just the URL parameters. But the URL might be subject to some mistreatment, besides the already mentioned %20->space conversion. It helps to be conservative in your URL syntax design. Don\'t throw in random // or you\'ll get into the mess that file:// is.</p>\n'}, {'answer_id': 38205984, 'author': 'Matas Vaitkevicius', 'author_id': 1509764, 'author_profile': 'https://Stackoverflow.com/users/1509764', 'pm_score': 7, 'selected': False, 'text': '<ol>\n<li><p>Go to <code>Start</code> then in <code>Find</code> type <code>regedit</code> -&gt; it should open Registry editor</p>\n</li>\n<li><p>Click <kbd>Right Mouse</kbd> on <code>HKEY_CLASSES_ROOT</code> then <code>New</code> -&gt; <code>Key</code></p>\n</li>\n</ol>\n<p><a href="https://i.stack.imgur.com/9boI6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9boI6.png" alt="enter image description here" /></a></p>\n<ol start="3">\n<li>In the Key give the lowercase name by which you want urls to be called (in my case it will be <code>testus://sdfsdfsdf</code>) then Click <kbd>Right Mouse</kbd> on <code>testus</code> -&gt;  then <code>New</code> -&gt; <code>String Value</code> and add <code>URL Protocol</code> without value.</li>\n</ol>\n<p><a href="https://i.stack.imgur.com/4wLev.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4wLev.png" alt="enter image description here" /></a></p>\n<ol start="4">\n<li>Then add more entries like you did with protocol ( <kbd>Right Mouse</kbd> <code>New</code> -&gt; <code>Key</code> ) and create hierarchy like <code>testus</code> -&gt; <code>shell</code> -&gt; <code>open</code> -&gt; <code>command</code> and inside <code>command</code> change <code>(Default)</code> to the path where <code>.exe</code> you want to launch is, if you want to pass parameters to your exe then wrap path to exe in <code>&quot;&quot;</code> and add <code> &quot;%1&quot;</code> to look like: <code>&quot;c:\\testing\\test.exe&quot; &quot;%1&quot;</code></li>\n</ol>\n<p><a href="https://i.stack.imgur.com/VbhsZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VbhsZ.png" alt="enter image description here" /></a></p>\n<ol start="5">\n<li>To test if it works go to Internet Explorer (not Chrome or Firefox) and enter <code>testus:have_you_seen_this_man</code> this should fire your <code>.exe</code> (give you some prompts that you want to do this - say Yes) and pass into args <code>testus://have_you_seen_this_man</code>.</li>\n</ol>\n<p>Here\'s sample console app to test:</p>\n<pre><code>using System;\n\nnamespace Testing\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            if (args!= null &amp;&amp; args.Length &gt; 0)\n            Console.WriteLine(args[0]);\n            Console.ReadKey();\n        }\n    }\n}\n</code></pre>\n<p>Hope this saves you some time.</p>\n'}, {'answer_id': 67330359, 'author': 'Shubham Kumar', 'author_id': 15748724, 'author_profile': 'https://Stackoverflow.com/users/15748724', 'pm_score': 2, 'selected': False, 'text': '<p>There is an npm module for this purpose.</p>\n<p>link :<a href="https://www.npmjs.com/package/protocol-registry" rel="nofollow noreferrer">https://www.npmjs.com/package/protocol-registry</a></p>\n<p>So to do this in nodejs you just need to run the code below:</p>\n<p>First Install it</p>\n<pre><code>npm i protocol-registry\n</code></pre>\n<p>Then use the code below to register you entry file.</p>\n<pre class="lang-js prettyprint-override"><code>const path = require(\'path\');\n\nconst ProtocolRegistry = require(\'protocol-registry\');\n\nconsole.log(\'Registering...\');\n// Registers the Protocol\nProtocolRegistry.register({\n    protocol: \'testproto\', // sets protocol for your command , testproto://**\n    command: `node ${path.join(__dirname, \'./index.js\')} $_URL_`, // $_URL_ will the replaces by the url used to initiate it\n    override: true, // Use this with caution as it will destroy all previous Registrations on this protocol\n    terminal: true, // Use this to run your command inside a terminal\n    script: false\n}).then(async () =&gt; {\n    console.log(\'Successfully registered\');\n});\n</code></pre>\n<p>Then suppose someone opens testproto://test\nthen a new terminal will be launched executing :</p>\n<pre><code>node yourapp/index.js testproto://test\n</code></pre>\n<p>It also supports all other operating system.</p>\n'}, {'answer_id': 73008905, 'author': 'duck', 'author_id': 343311, 'author_profile': 'https://Stackoverflow.com/users/343311', 'pm_score': 3, 'selected': False, 'text': '<p>If anyone wants a .reg file for creating the association, see below:</p>\n<pre><code>Windows Registry Editor Version 5.00\n\n[HKEY_CLASSES_ROOT\\duck]\n&quot;URL Protocol&quot;=&quot;&quot;\n[HKEY_CLASSES_ROOT\\duck\\shell]\n[HKEY_CLASSES_ROOT\\duck\\shell\\open]\n[HKEY_CLASSES_ROOT\\duck\\shell\\open\\command] \n@=&quot;\\&quot;C:\\\\Users\\\\duck\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.exe\\&quot; \\&quot;%1\\&quot;&quot;\n</code></pre>\n<p>Pasted that into notepad, the file -&gt; save as -&gt; duck.reg, and then run it. After running it, when you type <code>duck://arg-here</code> into chrome, ConsoleApp1.exe will run with &quot;arg-here&quot; as an argument. Double slashes are required for the path to the exe and double quotes must be escaped.</p>\n<p>Tested and working on Windows 11 with Edge (the chrome version) and Chrome</p>\n'}]
['https://Stackoverflow.com/questions/80650', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2189521/']