golang wails2.8 requireAdministrator 以管理员权限(UAC)运行解决闪退问题

1. 背景

基于wails2.8写了一个工具,在部分主机上运行的时闪退现象。

当右键选择以管理员身份运行时,则能正常使用。

可问题是,体验感不好,只能需求其他的解决方案

2. 资料

google了一圈,issue也看了一下,找了两位大佬的资料,尝试着去解决问题

资料1:

go windows程序使用管理员权限运行 - sanduo bloghttps://hksanduo.github.io/2021/04/28/2021-04-28-run-go-windows-software-with-administrator-priviledge/资料2:

Unable to Run App When Adding UAC Manifest to Go Executable · Issue #2625 · wailsapp/wails · GitHubDescription I am unable to run the app through wails dev when setting UAC for Windows manifest file. Got this err: FATAL: Unable to start application: fork/exec C:\MultiTech-Projects\GO Source Code Files\Web-Applications\Wails\xdot-contr...https://github.com/wailsapp/wails/issues/2625

3. 解决

修改项目中:build/windows/wails.exe.manifest 文件,添加以下代码

XML 复制代码
    // 以管理员身份运行
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="requireAdministrator" />
            </requestedPrivileges>
        </security>
    </trustInfo>

重新 wails build 打包,如果当前用户非管理员,运行时则会出现以下弹框,选择【是】,则程序正常运行

相关推荐
掘金码甲哥1 小时前
超性感的轻量级openclaw平替,我来给你打call
后端
用户8356290780514 小时前
无需 Office:Python 批量转换 PPT 为图片
后端·python
啊哈灵机一动4 小时前
使用golang搭建一个nes 模拟器
后端
间彧5 小时前
SpringBoot + ShardingSphere 读写分离实战指南
后端
砍材农夫5 小时前
订单超时
后端
树獭叔叔6 小时前
06-大模型如何"学习":从梯度下降到AdamW优化器
后端·aigc·openai
得鹿6 小时前
MySQL基础架构与存储引擎、索引、事务、锁、日志
后端
程序员飞哥6 小时前
Block科技公司裁员四千人,竟然是因为 AI ?
人工智能·后端·程序员
JavaEdge在掘金6 小时前
Claude Code 直连 Ollama / LM Studio:本地、云端开源模型都能跑
后端
LSTM976 小时前
使用 Python 将 TXT 转换为 PDF (自动分页)
后端