一、exe4j將jar打包成exe
1.exe4j下載
下載地址:https://www.ej-technologies.com/download/exe4j/files
2.exe4j打包jar
2.1. welcome 可以選擇歷史配置,新增則直接下一步
2.2. project type選擇“jar in exe” mode
2.3. application info設置應用名稱和輸出目錄
2.4. excutale info設置exe運行名稱、ico、jre位數
2.5. java invecation選擇可執行jar和main class,注意springboot為(org.springframework.boot.loader.JarLauncher)
2.6. jre設置版本
將jre復制一份到exe輸出目錄,并做如下配置,刪除多余依賴
2.7. splash screen 默認
2.8. messages 默認
2.9. comile executalbe編譯
2.10. finished驗證exe是否可執行
二、inno將exe打包成可安裝程序
1.inno下載
下載地址:https://jrsoftware.org/isinfo.php
2.inno將exe打包成可安裝程序
2.1. file->new新建
2.2. 應用信息名稱、版本、公司、官網地址
2.3. 安裝路徑設置
2.4. 安裝exe程序選擇
2.5. 安裝exe程序選擇,選擇jre
2.6. 安裝包名稱設置
2.7. 一些配置選項,可以直接默認
2.9. 選擇版權信息文件文件
2.10. 系統用戶使用權限等
2.11. 語言選擇,沒得中文...
2.12. 下一步,或者自己根據需要配置
2.13. 下一步
2.14. 完成
2.15. 先不執行腳本,修改一下腳本
修改注冊表配置
[Registry]
Root: HKCR; Subkey: "{#MyAppName}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}"; ValueType: string; ValueName: ""; ValueData: "URL:{#MyAppName} Protocol"; Flags: uninsdeletekey
Root: HKCR; Subkey: "{#MyAppName}"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""; Flags: uninsdeletekey
Root: HKCR; Subkey: "{#MyAppName}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKCR; Subkey: "{#MyAppName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
執行
安裝程序
三、vue中喚醒exe
1. 安裝custom-protocol-check
npm i?custom-protocol-check
2. 頁面代碼
<template><div class="container"><el-button type="primary" size="small" @click="loadexe()">喚醒exe</el-button></div>
</template>
<script lang="ts" setup name="LoadexeI18n">
import customProtocolCheck from "custom-protocol-check";
import { ElMessageBox } from "element-plus";
const loadexe = () => {customProtocolCheck("websockettest://params",() => {ElMessageBox.confirm("檢測到未安裝客戶端,請確認是否下載?").then(() => {window.location.href = "/software/mysetup.exe"}).catch(() => { });},() => {console.log("Custom protocol found and opened the file successfully.");}, 5000);
};
</script>
3. 源碼地址
演示地址:http://101.43.32.67:8081/login
vue3+elementplus+ts源碼:https://gitee.com/huanglgln/vue-sys-manage-el