A
A
Andrey Strelkov2020-04-16 09:38:56
Uniform Resource Identifier
Andrey Strelkov, 2020-04-16 09:38:56

How to create custom URI scheme handler?

Good afternoon, there is a task in the internal network and its sites to place links, when clicked on which a certain action took place on the client side

Namely, it turns out to designate your URI Scheme and, based on the context of the link using this scheme, to do this or that action on the user

side At first, I decided to test for the sake of designating the URI, when clicked on, which should open a notebook on the client side, with a parameter in the form of a link to a text document located in a certain network sphere.

To do this, I created the following link on the web page:

<a href="notepad:\\DESKTOP-M48FDKF\\somefolder\somefile.txt">Open txt file by notepad</a>


Then, on the client side, I created a new section in the registry.

5e97fc972400c051109338.png

5e97fc9da0315884762056.png

And then I decided to check by opening the browser and clicking on this link, warnings pop up from the browser (Microsoft Edge / Chromium) that this link is trying to open notepad, and are you sure about this?
I answer yes and get an error

Не удается найти файл C:\Program Files (x86)\Microsoft\Edge\Application\81.0.416.53\notepad:%5C%5CDESKTOP-M48FDKF%5C%5Csomefolder%5Csomefile.txt.

Вы хотите создать новый файл с таким именем?


And then I understand that most likely the problem is with specifying the path in the link on the web page, but I can’t figure out in what form the link should be given

. It looks like the problem is that the %1 parameter also stores the URI Scheme, i.e. not the value that comes after it, but the full notepad:\\DESKTOP-M48FDKF\\somefolder\somefile.txt
Please tell me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-04-16
@strelkov_av

how did you launch arbitrary programs using the link:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp]
"URL Protocol"=""
@="URL:Universal run app"

[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell]

[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell\open]

[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell\open\command]
@="mshta javascript:new(ActiveXObject)('WScript.Shell').Run(decodeURI('%1'.substr(7))),window.close()"

<a href="runapp:notepad C:\\Users\\User\\Desktop\\test.txt">Открыть test.txt</a>

if desired, you can make it so that only a specific application opens, but this is inconvenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question