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 打包,如果当前用户非管理员,运行时则会出现以下弹框,选择【是】,则程序正常运行

相关推荐
小白学大数据25 分钟前
Codex 里的 GPT 6 Astra、GPT 5.6 Sol、Terra、Luna 怎么选
开发语言·gpt·microsoft
l1t2 小时前
DeepSeek 4.1总结的Tom Lane 谈塑造 Postgres 三十年历程的架构决策
开发语言·数据库·postgresql·架构
djarmy8 小时前
MAIN.c(1): warning C318: can’t open file ‘STC8G.H’ 报错 解决 分析
c语言·开发语言·mongodb
HEJOO98 小时前
深入理解 Java volatile 关键字:原理、用法与常见误区
java·开发语言·spring
曹牧8 小时前
Java:no content to map due to end of input
java·开发语言
梦梦代码精8 小时前
《回收租赁系统技术选型避坑指南:业务闭环与二开自由度详解》
开发语言·低代码·docker·开源·代码规范
两点王爷8 小时前
SpringBoot 项目集成 GeoServer 源码,实现地图服务发布
java·spring boot·后端
隔窗听雨眠8 小时前
记一次SQL Server数据库性能分析:从CPU100%到单配置修复的完整诊断
开发语言·数据库·php
David猪大卫9 小时前
【C++修炼】智能指针使用及原理
开发语言·c++·经验分享·笔记·学习·考研·面试
charlie1145141919 小时前
现代Qt开发之图像处理进阶:像素操作与格式转换
开发语言·图像处理·qt