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

相关推荐
Meepo_haha5 分钟前
Spring Boot 条件注解:@ConditionalOnProperty 完全解析
java·spring boot·后端
sheji341616 分钟前
【开题答辩全过程】以 基于springboot的房屋租赁系统的设计与实现为例,包含答辩的问题和答案
java·spring boot·后端
Victor3561 小时前
MongoDB(57)如何优化MongoDB的查询性能?
后端
Victor3561 小时前
MongoDB(58)如何使用索引优化查询?
后端
行百里er1 小时前
优雅应对异常,从“try-catch堆砌”到“设计驱动”
java·后端·代码规范
娇娇yyyyyy1 小时前
QT编程(17): Qt 实现自定义列表模型
开发语言·qt
码财小子1 小时前
聊聊 C++ 模块“注册式”的优雅姿势
后端·代码规范
ms_27_data_develop2 小时前
Java枚举类、异常、常用类
java·开发语言
掘金码甲哥2 小时前
higress 这个中登才是AI时代的心头好
后端