2

I have created a custom protocol by name "myapp" and trying to pass arguments to it via href tag as <a href="myapp://E:/file.txt">Click here</a>.

myapp protocol is as described below:

[HKEY_CLASSES_ROOT\myapp]
@="\"URL:Alert Protocol\""
"URL Protocol"="\"\""

[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
@="\"C:\\WINDOWS\\System32\\notepad.exe,1\""

[HKEY_CLASSES_ROOT\myapp\shell]

[HKEY_CLASSES_ROOT\myapp\shell\open]

[HKEY_CLASSES_ROOT\myapp\shell\open\command]
@="\"C:\\WINDOWS\\System32\\notepad.exe\" \"%1\""

On clicking the anchor link it throws an error as "The filename, directory name, or volume label syntax is incorrect."

I guess the argument passed through <a href="myapp:E:/file.txt"> tag is not getting recognized.

I have no idea how to escape the slashes(/) or any special character here.

Please,help me with this or let me know if I am doing i wrong.

Pavlo
  • 43,301
  • 14
  • 77
  • 113

2 Answers2

2

The problem is that your command line has become

C:\WINDOWS\system32\notepad.exe myapp:E:/file.txt

I'm sure you were expecting it to be

C:\WINDOWS\system32\notepad.exe E:/file.txt

xinu-john
  • 21
  • 5
0

You have to do something like this to get the parameter also. Here I am getting the URL address as a parameter we pass in myapp:

var url = document.location.href ;
var arr = url.split("/");
var result = arr[0] + "//" + arr[2]
var uri='myapp://'+result;`
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
avaneesh
  • 31
  • 4