Web端打开本地可执行的exe程序
reg文件是注册表文件。
Web启动Colors.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Colors]
@="URL:Colors"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\Colors\shell]
[HKEY_CLASSES_ROOT\Colors\shell\open]
[HKEY_CLASSES_ROOT\Colors\shell\open\command]
@="D:\\Colors Lite\\Colors.exe"
双击这个reg文件把
Colors
写入注册表:

写入注册表成功如下:
定义一个方法openExe:
/**
* 打开本地可执行的exe程序
* @param href
*/
export function openExe (href) {
const a = document.createElement('a')
a.setAttribute('href', href)
a.click()
}
导入方法openExe并使用:
import { openExe } from './utils'
function openColors () {
openExe('Colors://')
},
每次在web端打开exe应用程序,浏览器都会默认弹窗。
Chrome_始终在关联的应用程序中打开此类型的链接:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies]
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google]
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"="1"
双击reg文件,写入注册表成功。
此时再次在web端打开exe应用程序,浏览器就不会再次默认弹窗了。