windowsregistryprotocol-handler

Manipulate %1 parameter in Registry Protocol Handler


In a web application we have links that have to be opened in another application. The idea now is to register a specific protocol handler to catch these links and send them to the target application.

The problem now is that the target application cannot handle the received parameter because it still contains the protocol.

Please consider following example:

Link to be opened in the web app should be my-protocol://my-info-to-pass.

In the registry we have defined the protocol handler for my-protocol as shell\open\command\(Default) = "path-to-my-app\my-app.exe" "%1".

So far it works as expected, but with the problem that the target application receives my-protocol://my-info-to-pass instead of only my-info-to-pass. The target application cannot handle this, so we simply have to strip off the first few characters.

I can remember, that some years ago we had a similar problem and that it was solved by some fancy command line syntax that manipulated %1 directly in the command line which is invoked by the handler. That solution is long gone and I searched the web up and down, but cannot find anything about it, nor remember how these mechanics were called.

If anyone can point me in the right direction as to what to look for, I would be very grateful.

I know, this could be solved by introducing some "middle man" solution like a batch file, but this would add complications in client configuration. A registry only solution could be done by DCM.


Solution

  • While my question was in staging for a day, I have found what we did years ago and the solution is ridiculously simple.

    It seems that the command of a protocol handler can take whatever can be put into a command prompt. The solution is to use

    cmd /C set data=%1 & call "path-to-my-app\my-app.exe" %%data:~14%%
    

    This example removes the first 14 characters (my-protocol://) and only 'my-info-to-pass' is sent to the app.