Created
November 3, 2023 03:02
-
-
Save lovemyliwu/88b29fb3d2f76b0bcfb87a652f15cd87 to your computer and use it in GitHub Desktop.
how to use custom url protocol to open folder on windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd /C "call set arg=%1% &&call set uri=%%arg:explorer://=%% && call echo %%uri%% && call C:\Windows\explorer.exe %%uri:/=\%%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
要使Chrome支持自定义协议app,您需要进行以下步骤:
创建一个注册表项:在Windows操作系统中,打开注册表编辑器(regedit),导航到HKEY_CLASSES_ROOT键下。在该键下创建一个新的子键,命名为您的自定义协议(例如,myapp)。
在新创建的子键下,创建一个名为"URL Protocol"的字符串值,并将其值设置为一个空字符串。
创建一个名为"shell"的子键,并在该子键下创建一个名为"open"的子键。
在"open"子键下,创建一个名为"command"的子键,并将其默认值设置为您的应用程序的可执行文件路径,以及您希望传递给应用程序的参数。例如,"C:\Path\to\your\app.exe %1"。
保存注册表编辑器中的更改,并关闭编辑器。
在您的网页中,使用您的自定义协议链接。例如,打开我的应用。
当用户点击链接时,Chrome将尝试启动您的应用程序,并将链接作为参数传递给应用程序。请注意,如果用户的计算机上没有安装您的应用程序,或者他们的浏览器没有正确配置自定义协议,那么该链接可能无法正常工作。
请注意,此方法仅适用于Windows操作系统。对于其他操作系统,可能需要其他方法来实现自定义协议的支持。