【问题标题】:VB.NET Program App run as administratorVB.NET Program App以管理员身份运行
【发布时间】:2014-03-18 15:16:08
【问题描述】:

我有一个可以正常工作的 VB.NET 应用程序,但是当我需要保存到文件时,我得到了拒绝访问文件夹,因为我的应用程序没有以管理员身份运行。

我已经在 NET 上尝试了所有方法,但我的应用仍然无法以管理员身份运行。

我做过的事情:

  • 使用<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 将清单文件添加到我的应用程序中
  • 创建了一个安装程序以在注册表中添加 RUNASADMIN 条目

但无济于事。基本上我的应用程序需要以某种方式设置以保存到程序文件夹中的本地文件。

关于如何解决此问题的任何想法?

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
    <!-- UAC Manifest Options
        If you want to change the Windows User Account Control level replace the 
        requestedExecutionLevel node with one of the following.

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

        Specifying requestedExecutionLevel node will disable file and registry virtualization.
        If you want to utilize File and Registry Virtualization for backward 
        compatibility then delete the requestedExecutionLevel node.
    -->
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
  </requestedPrivileges>
</security>

【问题讨论】:

  • 你能发布完整的配置文件吗
  • 您是否在您正在测试它的机器上禁用了 UAC?收到 UAC 提示了吗?
  • 焦点需要在文件夹上。所以我的 VB 应用程序保存到 XML 文件,除非我在管理员模式下运行应用程序,否则我无法保存到文件中。我可以从他们那里读到。该文件夹位于 Program Files(x86) 下
  • 尝试嵌入后发现,我需要将 XML 文件保存到 appdata 目录中。

标签: vb.net windows winforms security permissions


【解决方案1】:

尝试嵌入后,我需要将 XML 文件保存到 appdata 目录并保存在那里。这样 UAC 就不会干扰。

【讨论】:

    猜你喜欢
    • 2012-11-22
    • 2013-03-22
    • 1970-01-01
    • 2016-09-20
    • 2010-11-26
    • 2012-05-28
    • 2011-03-24
    • 2021-08-10
    • 1970-01-01
    相关资源
    最近更新 更多