2014-02-18 167 views
0

我有一个可以正常工作的VB.NET应用程序,但是当我需要保存到文件时,由于我的应用程序未以管理员身份运行,因此我得到拒绝的文件夹访问权限。以管理员身份运行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> 

+0

你可以发布完整的配置文件 – JaredPar

+0

你有没有在你测试的机器上禁用UAC?你有没有得到UAC提示? – Gray

+0

重点需要在文件夹上。所以我的VB应用程序保存到XML文件,除非我以管理员模式运行应用程序,否则我无法保存到文件中。我可以从他们那里读到。该文件夹位于Program Files(x86) – CJSoldier

回答

0

试图嵌入,我需要将XML文件保存到AppData目录加以保存后原来。这样UAC不会干涉。

相关问题