如何以管理员模式运行应用程序? [英] How do I deploy applications in run as administrator mode?

查看:185
本文介绍了如何以管理员模式运行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何部署应用程序,以便在没有最终用户手动执行的情况下才需要管理员权限?

How Do I deploy applications so that they require administrator rights without the end-user doing that by hand?

我使用Delphi 2009构建应用程序。 p>

I use Delphi 2009 to build the application.

推荐答案

您可以通过使用 requestedExecutionLevel 元素

清单文件是一个XML文件,如下所示。应该将它命名为 YourApp.exe.manifest ,并放在与可执行文件相同的文件夹中。 (它也可以嵌入在应用程序的资源中;它必须具有资源类型 RT_MANIFEST ,ID为1)

The manifest file is an XML file that looks as follows. It should be named YourApp.exe.manifest and placed in the same folder as the executable. (It can also be embedded in the resources of your application; it must have a resource type of RT_MANIFEST and an ID of 1.)

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="YourApp" type="win32"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

有关应用程序清单及其创建方法的更多详细信息,请参阅在MSDN上创建和嵌入应用程序清单(UAC)

For further details on application manifests and how to create them, see Create and Embed an Application Manifest (UAC) at MSDN.

请注意,清单仅受Windows Vista及更高版本的限制。如果您的用户在Windows XP上作为标准用户运行,则您的应用程序将不会以管理员身份启动;您可能需要编写代码才能检测到这一点,如果它是您的应用程序的一个问题。

Note that the manifest is only respected by Windows Vista and later. If your user is running as a standard user on Windows XP, your application will not be launched as an administrator; you may need to write code to detect this if it will be a problem for your application.

这篇关于如何以管理员模式运行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆