我有需要使用一些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需要控制台应用程序
发布评论