Show UAC prompt when launching an app

狂风中的少年 提交于 2019-12-10 10:20:45

问题


I have an app which needs administrator privileges to do some things. I'd like to just show the UAC prompt when it starts, and then be elevated. I'm not sure how to do this, but I'm hearing about things like manifests and whatnot but not seeing a plain answer anywhere.


回答1:


You need an app manifest that demands elevated privileges. Here's a quote from a blog that answers this:

First, you can create a manifest file by adding an “Application Manifest File” Item to your project (default name: app.manifest), then you can set it through the Application Tab in the Project Properties. If you want to change the Windows User Account Control level in your manifest file, all you need is to set the value of the level attribute of the requestedExecutionLevel node with one of the following:

  • asInvoker (default): the application will run using the current Windows user provileges
  • requireAdministrator: the application requires an Administrator user
  • highestAvailable: highest privileges for the current user will be used

http://dariosantarelli.wordpress.com/2007/11/21/vs2008-embedding-uac-manifest-options/



来源:https://stackoverflow.com/questions/1215443/show-uac-prompt-when-launching-an-app

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