如何授予我的 C# 应用程序管理权限?清单文件

发布于 2024-08-13 18:05:08 字数 749 浏览 11 评论 0原文

我在使用使用 win32_networkingadapterconfig 的 C# 应用程序时遇到一些问题。问题是,当我在没有管理员权限的用户上使用该应用程序时,我无法使用 win32_networkingadapterconfig 中的更改功能。我尝试过“以管理员身份运行”,但没有成功。我尝试在 trustInfo 部分中使用此内容制作一个清单文件:

<security>
  <applicationRequestMinimum>
    <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
    <defaultAssemblyRequest permissionSetReference="Custom" />
  </applicationRequestMinimum>
  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

  </requestedPrivileges>
</security>

启用 clickone 安全设置设为完全信任。我做错了什么?

I'm having some trouble with my C# app that uses win32_networkingadapterconfig. The problem is that I can't use the altering functions in win32_networkingadapterconfig when I use the app on a user that dont have admin rights. I have tried to "run as administrator", but no luck. And I have tried to make a manifestfile with this content in the trustInfo part:

<security>
  <applicationRequestMinimum>
    <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
    <defaultAssemblyRequest permissionSetReference="Custom" />
  </applicationRequestMinimum>
  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

  </requestedPrivileges>
</security>

Enable clickone security settings are set to full trust. What am I doing wrong ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

穿透光 2024-08-20 18:05:08

您的代码片段中有一个“trustinfo”。让它看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>

There's a "trustinfo" dangling in your snippet. Make it look like this:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
失退 2024-08-20 18:05:08

我按照我怀疑最有可能的顺序列出了许多可能的问题。

可能的问题1
你的UAC设置是什么?如创建并嵌入应用程序清单 (UAC) 中详细介绍的
如果您禁用了 UAC 并且您请求管理员权限

应用程序可能会启动,但稍后会失败

可能的问题 2
由于需要程序集信息,清单中的其他位置可能有问题。发布您的整个清单会有所帮助。

可能的问题3
您已添加 UAC 升级不需要的 applicationRequestMinimum 节点。也许值得放弃它并再次尝试。

There are a number of possible issues which I have listed in the order I suspect is most likely to less likely.

Possible Problem 1
What are your UAC settings? As detailed in Create and Embed an Application Manifest (UAC)
if you have UAC disabled and you request administrator permissions the

Application might launch but will fail later

Possible Problem 2
There could be something wrong else where in the manifest as the assembly information is required. Posting your whole manifest would help.

Possible Problem 3
You have added the applicationRequestMinimum node which is not required for UAC escalation. It may be worth dropping that and trying again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文