UAC需要控制台应用程序

编程入门 行业动态 更新时间:2024-10-27 01:22:25
本文介绍了UAC需要控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有需要使用一些code,它需要管理员级别的控制台应用程序。我已阅读,我需要补充的是看起来像一个清单文件myprogram.exe.manifest:

I have a console application that require to use some code that need administrator level. I have read that I need to add a Manifest file myprogram.exe.manifest that look like that :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator"> </requestedPrivileges> </security> </trustInfo> </assembly>

但它仍然没有提高UAC(在控制台或调试VS)。我该如何解决这个问题呢?

But it still doesn't raise the UAC (in the console or in debugging in VS). How can I solve this issue?

我能够让它工作,如果我运行在管理员的溶液或当我运行在管理员的/bin/*.exe。我仍然不知道是否有可能有一些会弹出当应用程序启动,而不是明确右击>以​​管理员身份运行?

I am able to make it work if I run the solution in Administrator or when I run the /bin/*.exe in Administrator. I am still wondering if it's possible to have something that will pop when the application start instead of explicitly right click>Run as Administrator?

推荐答案

您需要嵌入的UAC清单作为一个嵌入式Win32资源。请参见添加一个UAC清单来管理code 。

You need to embed the UAC manifest as an embedded Win32 resource. See Adding a UAC Manifest to Managed Code.

总之,您可以使用Windows SDK中的命令行工具嵌入到你的可执行文件。

In short, you use a Windows SDK command line tool to embed it into your executable.

您可以自动执行此作为生成后步骤通过将下面的行作为后生成任务在你的VS项目属性:

You can automate this as a post-build step by placing the following line as a post build task in your VS project's properties:

mt.exe -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"

更多推荐

UAC需要控制台应用程序

本文发布于:2023-11-15 19:25:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1597282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   应用程序   UAC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!