• web浏览器点击实现调用本地应用程序(exe)


    web浏览器点击实现调用本地应用程序(exe)

    1.注册表注册要调用的exe

    注册表注册要调用的exe
    nodejs child_process注册命令

    //不传递参数
    const execSync = require('child_process').execSync
    const cmd1 = `echo y| reg add HKCR\\client-r /v "URL Protocol" /t REG_EXPAND_SZ /d "E:\\r.exe"`;
    const cmd2 = `echo y| reg add HKCR\\client-r\\shell\\open\\command /t REG_EXPAND_SZ /d "E:\\r.exe"`;
    //传递参数
    const cmd3 = `echo y| reg add HKCR\\client-re /v "URL Protocol" /t REG_EXPAND_SZ /d "\"E:\\re.exe\" \"%1\""`;
    const cmd4 = `echo y| reg add HKCR\\client-re\\shell\\open\\command /t REG_EXPAND_SZ /d "\"E:\\r.exe\" \"%1\""`;
    const res4 = execSync(cmd4, { encoding: binaryEncoding }).toString();
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2.前端页面添加调用按钮

    前端页面添加调用按钮

    <!DOCTYPE html>
    <html lang="zh-cn">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>打开EXE</title>
    </head>
    <body>
      <a href="client-r://">调用1</a>
      <a href='client-re://,param1,'>调用2</a>
    </body>
    </html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    3.使用.bat调用exe

    bat文件调用的默认目录为C:\Windows\System32。
    使用.bat调用exe并传递相应参数。
    切换到bat脚本所在目录并需要传递2个参数。
    第一个参数为要执行的exe文件,第二个参数为exe执行所需参数。

    @echo off
    cd /d "%~dp0"
    @echo off
    start %2 %3
    
    • 1
    • 2
    • 3
    • 4

    问题:bat脚本执行时弹出黑窗
    处理方式:使用Bat to Exe Converter将bat文件转换为exe文件,选择EXE格式:32位|Windows(隐形),点击转换。
    在这里插入图片描述

  • 相关阅读:
    Retic 功放的使用方法
    下秒数据CEO蔡致暖:云原生时代数据管道的迭代之路
    Linux当中如何隐藏和查看进程
    vue的diff算法
    linux编程与基础:第二章命令与开发工具--自我总结
    Win11系统禁止关机键关机的方法教学
    Cookie与Session详解
    跳房子 I
    渗透测试面试中常见的问题收集(部分)
    获得反射对象
  • 原文地址:https://blog.csdn.net/baidu_37336262/article/details/126287169