我能否使用自定义 URI 协议将用户计算机上的“默认 PDF 查看器”从浏览器打开到特定的远程文件?

问题描述 投票:0回答:2

我想假设 URL annotate://\REMOTESERVER1\path o emote ile.pdf 在 Windows 用户的机器上打开默认的 PDF 阅读器,并打开远程文件,而不是在本地下载和打开它。我从命令行知道以下工作:

start \\REMOTESERVER1\path\to\remote\file.pdf

我已使用以下说明将密钥添加到注册表中: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)?redirectedfrom=MSDN

我在“命令”值中尝试了以下内容:

  • 将其注册到“C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe”,不带任何变量 - 成功启动 Acrobat
  • 将其注册到“C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe”并硬编码文档的完整路径 - 在 Acrobat 中成功启动文档
  • 将其注册到 "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "%1"(带引号和不带引号)- 失败。 Acrobat 说路径的语法无效。我尝试了各种 URI 编码方案并在斜杠中转义,但也许我遗漏了什么?
  • 注册“开始”(带/不带引号)和完整文件路径的不同组合 - 失败;甚至不尝试打开 Acrobat。

注:

  • 这些都是 Windows 用户
  • 这些用户都将在能够访问此远程文件的 VPN 上
  • 这些用户都将使用 Adobe Acrobat,但他们可能使用不同的版本,因此想要加载“默认 PDF 查看器”

Acrobat 似乎没有内置任何东西来捕获自定义 URI 协议。有解决办法吗?

pdf registry uri acrobat
2个回答
0
投票

旧线程,但仍然需要答案。

应用程序协议 URI 将整个 URI 作为参数传递,而不仅仅是您希望作为参数的部分。因此,当您形成链接

acrobat:my.pdf
时,作为
HKEY_CLASSES_ROOT\acrobat\shell\open\command
进入
%1
的不是
my.pdf
,而是
acrobat:my.pdf

替换

Computer\HKEY_CLASSES_ROOT\acrobat\shell\open\command\Default
=
"C:\program files\adobe\acrobat DC\acrobat\acrobat.exe" "%1"

Default
=
cmd /v:on /c "SET _invocation=%1 & "C:\program files\adobe\acrobat DC\acrobat\acrobat.exe" !_invocation:acrobat:=!"

是一种绕过它的方法。

编辑:关于这个的几个注释。

这确实适用于 SharePoint 以正确签出文件,使“保存”工作而不是强制执行“另存为”。

以上内容与其他已打开的 Acrobat 窗口/选项卡的播放效果不佳。要解决此问题,请删除

Computer\HKEY_CLASSES_ROOT\acrobat\shell\open\ddeexec
或删除该键和子键的值。

这引发了另一个更新问题,总是恢复

ddeexec
键。虽然
command
键持续更新,但如果使用“将 adobe 设置为默认值”,它会被重置。

所以要解决这一切,只需制定一个新协议“adobe”:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\adobe]
@="URL:PDF Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\adobe\DefaultIcon]
@="C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe"

[HKEY_CLASSES_ROOT\adobe\shell]
@="Open"

[HKEY_CLASSES_ROOT\adobe\shell\open]
@="Open with Adobe Acrobat"

[HKEY_CLASSES_ROOT\adobe\shell\open\command]
@="cmd /v:on /c \"SET _invocation=%1 & start \"\" \"C:\\program files\\adobe\\acrobat DC\\acrobat\\acrobat.exe\" !_invocation:adobe:=!\""

0
投票

如果要使用 HTTP 访问文件,Adobe Reader 不能使用 URL 作为参数。所以补充 retrotube 答案,打开命令可以写成:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\adobe]
@="URL:PDF Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\adobe\DefaultIcon]
@="C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe"

[HKEY_CLASSES_ROOT\adobe\shell]
@="Open"

[HKEY_CLASSES_ROOT\adobe\shell\open]
@="Open with Adobe Acrobat"

[HKEY_CLASSES_ROOT\adobe\shell\open\command]
@="cmd /v:on /c \"SET _invocation=%1 & SET _sfile=!_invocation:~6! & SET _dfile=!temp!\\!random!-!random!-!random!.pdf & curl -o !_dfile! !_sfile! & start \"\" \"C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe\" !_dfile!"
© www.soinside.com 2019 - 2024. All rights reserved.