参考文章:https://blogs.msdn.microsoft.com/ieinternals/2011/07/13/understanding-protocols/
浏览器调用客户端的程序。(以调用secureCRT为例)
以下内容创建注册表:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\yourname]
@="Url:yourname Protocol"
"URL Protocol"="D:\\Program Files\\SecureCRT\\SecureCRT.exe"
"UseOriginalUrlEncoding"=dword:00000001
[HKEY_CLASSES_ROOT\yourname\DefaultIcon]
@="D:\\Program Files\\SecureCRT\\SecureCRT.exe,1"
[HKEY_CLASSES_ROOT\yournamet\shell]
[HKEY_CLASSES_ROOT\yourname\shell\open]
[HKEY_CLASSES_ROOT\yourname\shell\open\command]
@="\"D:\\Program Files\\SecureCRT\\SecureCRT.exe\" \"%1\""
页面调用的时候写:
注意注册表的这一句:
@="\"D:\\Program Files\\SecureCRT\\SecureCRT.exe\" \"%1\""
有些blog的说明:%1是去掉自定义协议头的参数部分。比如示例中的页面代码,%1 是去掉 yourname:// 留下的 “/param1”
但是,个人测试结果:传递的是yourname:///param1也就是整个URL,而且ff、chrome,还对url进行了urlEncode,空格转化为%20
(注册表里的UseOriginalUrlEncoding = 1,起的作用是能让encode采取统一的格式,详细说明请参见篇头的文章)
好~~问题来了:
比如调用 SecureCRT.exe /SSH2 /L root /P 22 /PASSWORD xxxxx 1.1.1.1
SecureCRT.exe yourname:///SSH2 /L root /P 22 /PASSWORD xxxxx 1.1.1.1
或者
SecureCRT.exe yourname:///SSH2%20/L%20root%20/P%2022%20/PASSWORD%20xxxxx%201.1.1.1
我的办法是写了一个bat,注册表指向它,他再解析参数,调用secureCRT
有没有更好的方法?