您可以參考:Registering an Application to a URI Scheme
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\alert]
@="URL:Alert Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\alert\DefaultIcon]
[HKEY_CLASSES_ROOT\alert\shell]
[HKEY_CLASSES_ROOT\alert\shell\open]
[HKEY_CLASSES_ROOT\alert\shell\open\command]
@="\"C:\\\\Windows\\explorer.exe\" \"\\\\192.168.255.27\\sub\\someone\""
完成之後,就能在chrome的url中,輸入:alert:
即可執行需的程式
也可以使用批次檔:
@echo off
SET /p "protocol_name=input protocl name:"
REG ADD "HKCR\%protocol_name%" /V "URL Protocol" /t REG_SZ
REG ADD "HKCR\%protocol_name%\shell\open\command" /t REG_SZ /F /D "\"%SystemRoot%\explorer.exe\" \"%%1\""
echo down & PAUSE > nul
command中的執令記得換成自己的
在開始前,請先快速看過此篇文章
這篇教你可以更改: %localappdata%\Google\Chrome\User Data\Default\
中的Preferences
檔案
搜尋protocol_handler
一定可以找的到東西
而我們先補上
"protocol_handler":{"excluded_schemes":{"someothersoftware":false,"nd":false}}
以上的例子是排除someothersoftware, nd兩項內容
不過這個例子我沒有成功,貌似不適用現行的chrome版本
URLAllowlist 政策的優先順序高於 URLBlocklist。最多只能為這項政策輸入1000 個項目。
Software\Policies\Google\Chrome\URLAllowlist\1 = example.com
你可以使用batch檔來新增
@REG ADD "HKLM\SOFTWARE\Policies\Google\Chrome\URLAllowlist" /V "1" /t REG_SZ /f /D "alert:*"
或者您要用reg的檔案新增也可以
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\URLAllowlist]
"1"="alert:*"
URLAllowlist 政策的優先順序高於 URLBlocklist。最多只能為這項政策輸入1000 個項目。 ↩︎