Forcing my MFC app to run as Administrator on Vista

天涯浪子 提交于 2019-12-05 21:02:46

I found out how to do this using some advanced C++ linker options:

  1. Open the project's Property Pages dialog box.

  2. Expand the Configuration Properties node.

  3. Expand the Linker node.

  4. Select the Manifest File property page.

  5. Modify the Enable User Account Control (UAC), UAC Execution Level, and UAC Bypass UI Protection properties.

You can do this using the manifest. Possibly something like this but I can't recall exactly:

<requestedExecutionLevel level="requireAdministrator"/>

You can do either. You can add a similar line with a #pragma to add the requireAdministrator directive, or you can set it in the property sheets in VS2008.

  1. Select the project in question, go to menu Project > Properties.

  2. Navigate to Configuration Properties > Linker > Manifest File.

  3. In the UAC Execution Level entry, select the option

requireAdministrator (/level='requireAdministrator')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!