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

相关推荐
橘橙黄又青4 小时前
Spring篇
java·后端·spring
JaredYe4 小时前
node-plantuml-2:革命性的纯Node.js PlantUML渲染器,告别Java依赖!
java·开发语言·node.js·uml·plantuml·jre
hhzz4 小时前
Springboot项目中使用EasyPOI方式导出合同word文档
java·spring boot·后端·word·poi·easypoi
派大鑫wink4 小时前
【Day38】Spring 框架入门:IOC 容器与 DI 依赖注入
java·开发语言·html
rit84324994 小时前
基于偏振物理模型的水下图像去雾MATLAB实现
开发语言·matlab
爱丽_4 小时前
Spring Bean 管理与依赖注入实践
java·后端·spring
kklovecode4 小时前
数据结构---顺序表
c语言·开发语言·数据结构·c++·算法
独自破碎E4 小时前
什么是Spring Bean?
java·后端·spring
孩子 你要相信光4 小时前
解决:React 中 map 处理异步数据不渲染的问题
开发语言·前端·javascript
jllllyuz4 小时前
ANPC三电平逆变器损耗计算的MATLAB实现
开发语言·matlab·php