前端JS实现启动本地.exe客户端程序

前端JS实现启动本地.exe客户端程序

使用url protocol 的方式来实现,亲测可行

步骤1:
先要写入注册表,先注册URL PROTOCOL, 在windows 下就是注册表,保存内容为 reg文件(myprotocol.reg),然后执行,就加入注册表,注册了这个名字为myprotocol 的协议.

使用文本新建.txt 写入以下内容,然后修改后缀名为.reg ,双击执行

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\myprotocol]
@="myprotocol Protocol"
"URL Protocol"= ""

[HKEY_CLASSES_ROOT\myprotocol\DefaultIcon]
@="D:\\soft\\WeChat\\WeChat.exe"   // 我这里假设启动的是微信,注意用

[HKEY_CLASSES_ROOT\myprotocol\shell]
@= ""

[HKEY_CLASSES_ROOT\myprotocol\shell\open]
@= ""

[HKEY_CLASSES_ROOT\myprotocol\shell\open\command]
@="\"D:\\soft\\WeChat\\WeChat.exe\"" // 我这里假设启动的是微信

步骤2:
测试页面

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="public/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>前端JS实现启动本地.exe客户端程序</title>
  </head>
  <body>
    <a href="myprotocol://">
                打开程序
            </a>

  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值