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

相关推荐
码兄科技6 小时前
实战:基于Spring Boot + UniApp的地理信息小程序开发
spring boot·后端·uni-app
程序喵大人6 小时前
【C++进阶】STL容器与迭代器 - 01 STL 容器先解决元素放在哪里
开发语言·c++·stl
cui_ruicheng7 小时前
Python从入门到实战(十六):多进程编程
开发语言·python
腾讯云云开发7 小时前
腾讯云 CloudBase 登上 WAIC:我们为 Agent 重新设计了云的生产线
后端
星栈7 小时前
从装一堆工具到看懂 Node 工程化思维:我的项目复盘记录
后端·node.js
65岁退休Coder8 小时前
LangChain v1.3.4 笔记 - 05 Agent 上下文记忆
后端
颜酱8 小时前
04 | 召回前置准备:搭好召回所需的四个数据库
前端·人工智能·后端
wdfk_prog8 小时前
嵌入式面试真题第 15 题:不可恢复异常后的通用崩溃快照、调用栈保存与离线分析架构
linux·开发语言·面试·架构
JaneConan8 小时前
鸿蒙 韶非 UI 系列:能力调用 startAbilityForResult,跳能力拿回参,鸿蒙能力路由入门
后端·harmonyos
晴空了无痕8 小时前
从 Go 基础到 K8s:一条可落地的 Go 服务端成长路线
开发语言·后端·golang·kubernetes