将Windows磁盘路径转换为注册表文件中的Uri路径
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Windows磁盘路径转换为注册表文件中的Uri路径相关的知识,希望对你有一定的参考价值。
正如我在问题中已经提到的,我正在尝试将Windows路径转换为注册表文件中的Uri路径。
然后按照下面的代码所示,将转换后的Uri路径复制到剪贴板:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Copy As Uri Info]
[HKEY_CLASSES_ROOT\*\shell\Copy As Uri Info\command]
@="cmd.exe /q /v:on /e:on /c \"set FilePath=\"%1\" & set UriPath=file:///%%FilePath:\=/%% & echo !UriPath!|clip\""
[HKEY_CLASSES_ROOT\Directory\shell\Copy As Uri Info]
[HKEY_CLASSES_ROOT\Directory\shell\Copy As Uri Info\command]
@="cmd.exe /q /v:on /e:on /c \"set FilePath=\"%1\" & set UriPath=file:///%%FilePath:\=/%% & echo !UriPath!|clip\""
但是当我运行此注册表文件,然后右键单击并在任何文件或文件夹上选择“复制为Uri信息”时,它将复制“!UriPath!”。放入剪贴板。
任何人都可以帮忙吗?
答案
尝试将"%%"
替换为"!"
,并在需要的地方添加转义:
- 对于命令行:
reg delete "HKEY_CLASSES_ROOT\*\shell\Copy As Uri Info" /f
reg delete "HKEY_CLASSES_ROOT\Folder\shell\Copy As Uri Info" /f
reg delete "HKEY_CLASSES_ROOT\Directory\shell\Copy As Uri Info" /f
REG ADD "HKCR\*\shell\Copy As Uri Info\command" /V "" /D "cmd.exe /v /c \"set \"FilePath=%1\"^&^&set \"UriPath=file:///!FilePath:\\=/!\"^&^&cmd /v/cecho=!UriPath!^|clip\""
REG ADD "HKCR\Folder\shell\Copy As Uri Info\command" /V "" /D "cmd.exe /v /c \"set \"FilePath=%1\"^&^&set \"UriPath=file:///!FilePath:\\=/!\"^&^&cmd /v/cecho=!UriPath!^|clip\""
REG ADD "HKCR\Directory\shell\Copy As Uri Info\command" /V "" /D "cmd.exe /v /c \"set \"FilePath=%1\"^&^&set \"UriPath=file:///!FilePath:\\=/!\"^&^&cmd /v/cecho=!UriPath!^|clip\""
- 对于Reg文件:
Windows Registry Editor Version 5.00
[-HKCR\*\shell\Copy As Uri Info]
[-HKCR\Folder\shell\Copy As Uri Info]
[-HKCR\Directory\shell\Copy As Uri Info]
[HKCR\*\shell\Copy As Uri Info\command]
@="cmd.exe /v /c \"set \"FilePath=%1\"&&set \"UriPath=file:///!FilePath:\\=/!\"&&cmd /v/cecho=!UriPath!^|clip\""
[HKCR\Folder\shell\Copy As Uri Info\command]
@="cmd.exe /v /c \"set \"FilePath=%1\"&&set \"UriPath=file:///!FilePath:\\=/!\"&&cmd /v/cecho=!UriPath!^|clip\""
[HKCR\Directory\shell\Copy As Uri Info\command]
@="cmd.exe /v /c \"set \"FilePath=%1\"&&set \"UriPath=file:///!FilePath:\\=/!\"&&cmd /v/cecho=!UriPath!^|clip\""
以上是关于将Windows磁盘路径转换为注册表文件中的Uri路径的主要内容,如果未能解决你的问题,请参考以下文章
使用 React-Native 将 content:// URI 转换为 Android 的实际路径
使用 typescript 使用 data-uri 将图像转换为 base64